extend tests
authorLaurent MAZET <laurent.mazet@thalesgroup.com>
Mon, 5 Oct 2026 15:58:28 +0000 (17:58 +0200)
committerLaurent MAZET <laurent.mazet@thalesgroup.com>
Mon, 5 Oct 2026 15:58:28 +0000 (17:58 +0200)
html2txt.c

index 94b1b07f1cff1d72dec136f87d4969cfc71bc825..2b5183fd34d35da0a7a5aed4d861210013e59507 100644 (file)
@@ -135,9 +135,10 @@ int main (int argc, char *argv[])
             break;
         case '&':
             if (pt[1] == '#') {
-                pt += 1 + check_code (pt + 2, out);
+                pt += check_code (pt + 2, out);
                 if (*out != '\0') {
                     glyph = out;
+                    pt++;
                 }
             } else {
                 pt += check_element (pt + 1, &glyph);
@@ -148,6 +149,7 @@ int main (int argc, char *argv[])
                 }
             } else {
                 strncpy (out, pt, 1);
+                out[1] = '\0';
             }
             break;
         default:
@@ -165,11 +167,16 @@ int main (int argc, char *argv[])
 }
 
 /* test: html2txt.exe -h | grep usage */
+/* test: html2txt.exe x 2>&1 | grep 'invalid option' */
+/* test: html2txt.exe -x 2>&1; test $? -eq 1 */
 /* test: html2txt.exe -i 2>&1 | grep missing */
 /* test: html2txt.exe -v 2>&1 | grep missing */
 /* test: html2txt.exe -i foobar 2>&1 | grep "can't open file" */
 /* test: echo '<b>foo</b>b<p class="main">a</p>r' | html2txt.exe | grep '^foobar$' */
 /* test: echo 'f&#6f;&#6F;&#62;&#0061;r' | html2txt.exe | grep '^foobar$' */
+/* test: echo '&#6f6F' | html2txt.exe -v 1| grep '^&#6f6F$' */
+/* test: echo '&#foobar' | html2txt.exe -v 1| grep '^&#foobar$' */
+/* test: echo '&foobar' | html2txt.exe -v 2 | grep '^&foobar' */
 /* test: html2txt.exe -i test.html >/dev/null */
 
 /* vim: set ts=4 sw=4 et: */