Get l_to_python working again, implement more necessary features such as sizeof
[c_to_python.git] / tests / scan.l
index 73e1b5f..62d9fe1 100644 (file)
@@ -139,7 +139,7 @@ void piece_append(const char *str);
 void piece_insert(int n, const char *str);
 void piece_escape(const char *p, size_t n);
 void piece_flush(size_t n);
-void piece_pack();
+void piece_pack(void);
 
 static void markup_action(const char *text);
 static void markup_option(const char *name, int sense);
@@ -1310,6 +1310,14 @@ void piece_insert(int n, const char *str) {
 void piece_escape(const char *p, size_t n) {
  size_t i, j = 0;
  for (i = 0; i < n; ++i)
+#if 1 /* switch not implemented yet in c_to_python */
+  if (p[i] == '<' || p[i] == '>')
+   j += 4;
+  else if (p[i] == '&')
+   j += 5;
+  else
+   ++j;
+#else
   switch (p[i]) {
   case '<':
   case '>':
@@ -1322,9 +1330,26 @@ void piece_escape(const char *p, size_t n) {
    ++j;
    break;
   }
+#endif
  char *q = malloc(j + 1);
  j = 0;
  for (i = 0; i < n; ++i)
+#if 1 /* switch not implemented yet in c_to_python */
+  if (p[i] == '<') {
+   memcpy(q + j, "&lt;", 4);
+   j += 4;
+  }
+  else if (p[i] == '>') {
+   memcpy(q + j, "&gt;", 4);
+   j += 4;
+  }
+  else if (p[i] == '&') {
+   memcpy(q + j, "&amp;", 5);
+   j += 5;
+  }
+  else
+   q[j++] = p[i];
+#else
   switch (p[i]) {
   case '<':
    memcpy(q + j, "&lt;", 4);
@@ -1342,6 +1367,7 @@ void piece_escape(const char *p, size_t n) {
    q[j++] = p[i];
    break;
   }
+#endif
  q[j] = 0;
  piece[piece1++] = q;
 }
@@ -1351,7 +1377,7 @@ void piece_flush(size_t n) {
  yytext += n;
 }
 
-void piece_pack() {
+void piece_pack(void) {
  int i;
  size_t j = 0;
  for (i = piece0; i < piece1; ++i)