summaryrefslogtreecommitdiff
path: root/sqesc.c
blob: 6d7ba23a49510c86402ab1a6c0cf70c804047dec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <string.h>

int print_escaped(char *s) {
  char *p=0;
  for(p=strchr(s,'\'');p && s && *p && *s;p=strchr(s,'\'')) {
    *p=0;//null out this single-quote
    printf("%s",s);
    printf("'\\''");
    s=p+1;
  }
  printf("%s",s);
  return 0;
}

int main(int argc,char *argv[]) {
  return print_escaped(argv[1]);
}