Diff
Not logged in

Differences From:

File src/translate.c part of check-in [dbda8d6ce9] - Initial check-in of m1 sources. by drh on 2007-07-21 14:10:57. [view]

To:

File src/translate.c part of check-in [d5e7891b07] - Add a more advanced commit-hook mechanism that allows us to specify multiple procedures in a particular order prior to commit. Continuing work toward getting tickets going. by drh on 2007-11-18 20:48:07. Also file src/translate.c part of check-in [d0305b305a] - Merged mainline into my branch to get the newest application. by aku on 2007-12-05 08:07:46. [view]

@@ -76,24 +76,32 @@
 ** Translate the input stream into the output stream
 */
 static void trans(FILE *in, FILE *out){
   int i, j, k;        /* Loop counters */
+  char c1, c2;        /* Characters used to start a comment */
   int lastWasEq = 0;  /* True if last non-whitespace character was "=" */
   char zLine[2000];   /* A single line of input */
   char zOut[4000];    /* The input line translated into appropriate output */
 
+  c1 = c2 = '-';
   while( fgets(zLine, sizeof(zLine), in) ){
     for(i=0; zLine[i] && isspace(zLine[i]); i++){}
     if( zLine[i]!='@' ){
       if( inPrint || inStr ) end_block(out);
       fprintf(out,"%s",zLine);
+                       /* 0123456789 12345 */
+      if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
+        c1 = zLine[14];
+        c2 = zLine[15];
+      }
       i += strlen(&zLine[i]);
       while( i>0 && isspace(zLine[i-1]) ){ i--; }
       lastWasEq = i>0 && zLine[i-1]=='=';
     }else if( lastWasEq ){
       /* If the last non-whitespace character before the first @ was
-      ** an "=" then generate a string literal.  But skip SQL comments
-      ** consisting of all text between "--" and end of line.
+      ** an "=" then generate a string literal.  But skip comments
+      ** consisting of all text between c1 and c2 (default "--")
+      ** and end of line.
       */
       int indent, omitline;
       i++;
       if( isspace(zLine[i]) ){ i++; }
@@ -100,9 +108,11 @@
       indent = i - 2;
       if( indent<0 ) indent = 0;
       omitline = 0;
       for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
-        if( zLine[i]=='-' && zLine[i+1]=='-' ){ omitline = 1; break; }
+        if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
+           omitline = 1; break;
+        }
         if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
         zOut[j++] = zLine[i];
       }
       while( j>0 && isspace(zOut[j-1]) ){ j--; }