Fossil

Check-in [b5e2e500]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:This change allows html entities (like → and •) in all c-sources to be replaced by its utf-8 equivalent (→,•). The translate utility will translate this to the right escape-sequence, so the C-compiler can handle it.
As long as the C-source doesn't contain any utf-8 characters, this generates exactly the same *_.c files as before.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | utf8-in-sources
Files: files | file ages | folders
SHA1:b5e2e50040aadecf59edce7b86588adfaf20ed79
User & Date: jan.nijtmans 2012-08-28 06:24:23
Original Comment: This change allows utf-8 characters (like → and •) in all c-sources to be replaced by its utf-8 equivalent. The translate utility will translate this to the right escape-sequence, so the C-compiler can handle it. As long as the C-source contains nu utf-8 characters, this generates exactly the same *_.c files as before.
Context
2012-08-29
13:03
merge trunk Closed-Leaf check-in: e9f38ae8 user: jan.nijtmans tags: utf8-in-sources
2012-08-28
06:24
This change allows html entities (like → and •) in all c-sources to be replaced by its utf-8 equivalent (→,•). The translate utility will translate this to the right escape-sequence, so the C-compiler can handle it.
As long as the C-source doesn't contain any utf-8 characters, this generates exactly the same *_.c files as before.
check-in: b5e2e500 user: jan.nijtmans tags: utf8-in-sources
2012-08-27
22:56
Make merges a no-op if the pivot is the same as the version being merged. check-in: bf079432 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/translate.c.

1
2
3
4
5
6
7
8
9
..
74
75
76
77
78
79
80

81
82
83







84
85
86









87
88
89
90
91
92
93
94
...
108
109
110
111
112
113
114




115

116
117
118
119
120
121
122
...
132
133
134
135
136
137
138




139

140
141
142
143
144
145
146
/*
** Copyright (c) 2002 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)

** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
................................................................................
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 "=" */
  int lastWasComma = 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--; }
................................................................................
      if( indent<0 ) indent = 0;
      omitline = 0;
      for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
        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--; }
      zOut[j] = 0;
      if( j<=0 && omitline ){
        fprintf(out,"\n");
      }else{
        fprintf(out,"%*s\"%s\\n\"\n",indent, "", zOut);
................................................................................
      int nC;
      char c;
      i++;
      if( isspace(zLine[i]) ){ i++; }
      indent = i;
      for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
        if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }




        zOut[j++] = zLine[i];

        if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
        for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
        if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
        while( --nC ) zOut[j++] = zLine[++i];
        zArg[nArg++] = ',';
        k = 0; i++;
        while( (c = zLine[i])!=0 ){

|







 







>



>
>
>
>
>
>
>



>
>
>
>
>
>
>
>
>
|







 







>
>
>
>
|
>







 







>
>
>
>
|
>







1
2
3
4
5
6
7
8
9
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
** Copyright © 2002 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)

** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
................................................................................
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 "=" */
  int lastWasComma = 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 */
  int isFirstline = 1;  /* True if this is the first line */

  c1 = c2 = '-';
  while( fgets(zLine, sizeof(zLine), in) ){
    if (isFirstline) {
      static const char bom[] = { 0xEF, 0xBB, 0xBF };
      if( memcmp(zLine, bom, 3)==0 ) {
    	  memmove(zLine, zLine+3, sizeof(zLine)-3);
      }
      isFirstline = 0;
    }
    for(i=0; zLine[i] && isspace(zLine[i]); i++){}
    if( zLine[i]!='@' ){
      if( inPrint || inStr ) end_block(out);
      for(j=0; zLine[i]; i++){
        if (128 <= (unsigned char)zLine[i]) {
          sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
          j += 5;
        } else {
          zOut[j++] = zLine[i];
        }
      }
      zOut[j] = 0;
      fprintf(out,"%s",zOut);
                       /* 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--; }
................................................................................
      if( indent<0 ) indent = 0;
      omitline = 0;
      for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
        if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
           omitline = 1; break; 
        }
        if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
        if (128 <= (unsigned char)zLine[i]) {
          sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
          j += 5;
        } else {
          zOut[j++] = zLine[i];
        }
      }
      while( j>0 && isspace(zOut[j-1]) ){ j--; }
      zOut[j] = 0;
      if( j<=0 && omitline ){
        fprintf(out,"\n");
      }else{
        fprintf(out,"%*s\"%s\\n\"\n",indent, "", zOut);
................................................................................
      int nC;
      char c;
      i++;
      if( isspace(zLine[i]) ){ i++; }
      indent = i;
      for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
        if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
        if (128 <= (unsigned char)zLine[i]) {
          sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
          j += 5;
        } else {
          zOut[j++] = zLine[i];
        }
        if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
        for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
        if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
        while( --nC ) zOut[j++] = zLine[++i];
        zArg[nArg++] = ',';
        k = 0; i++;
        while( (c = zLine[i])!=0 ){