From 1c687aba0c003d7ac50ae3435baf9da584ab5c55 Mon Sep 17 00:00:00 2001
From: anon <anon@anon.anon>
Date: Mon, 12 Feb 2024 21:07:48 +0100
Subject: [PATCH] directory ordering

---
 .gitignore                                    |  1 +
 Makefile.am                                   | 42 +++++++++----------
 configure.ac                                  |  4 +-
 source/.dirstamp                              |  0
 exec.c => source/exec.c                       |  0
 lib.c => source/lib.c                         |  0
 main.c => source/main.c                       |  3 +-
 sql-parser.h => source/sql-parser.h           |  0
 sql.l => source/sql.l                         |  2 +-
 sql.y => source/sql.y                         | 11 +----
 yyl.h => source/yyl.h                         |  0
 fail1.sql => test/fail1.sql                   |  0
 fail3.sql => test/fail3.sql                   |  0
 fail4.sql => test/fail4.sql                   |  0
 fail5.sql => test/fail5.sql                   |  0
 ok1.sql => test/ok1.sql                       |  0
 ok10.sql => test/ok10.sql                     |  0
 ok2.sql => test/ok2.sql                       |  0
 ok3.sql => test/ok3.sql                       |  0
 ok4.sql => test/ok4.sql                       |  0
 ok5.sql => test/ok5.sql                       |  0
 ok6.sql => test/ok6.sql                       |  0
 ok7.sql => test/ok7.sql                       |  0
 ok8.sql => test/ok8.sql                       |  0
 ok9.sql => test/ok9.sql                       |  0
 test-fail.sh => test/test-fail.sh             |  6 ++-
 test-ok.sh => test/test-ok.sh                 |  6 ++-
 tst-create-db.sql => test/tst-create-db.sql   |  0
 .../tst-create-table.sql                      |  0
 tst-delete.sql => test/tst-delete.sql         |  0
 tst-drop-db.sql => test/tst-drop-db.sql       |  0
 tst-drop-table.sql => test/tst-drop-table.sql |  0
 tst-insert.sql => test/tst-insert.sql         |  0
 xfail2.sql => test/xfail2.sql                 |  0
 34 files changed, 37 insertions(+), 38 deletions(-)
 create mode 100644 source/.dirstamp
 rename exec.c => source/exec.c (100%)
 rename lib.c => source/lib.c (100%)
 rename main.c => source/main.c (96%)
 rename sql-parser.h => source/sql-parser.h (100%)
 rename sql.l => source/sql.l (99%)
 rename sql.y => source/sql.y (99%)
 rename yyl.h => source/yyl.h (100%)
 rename fail1.sql => test/fail1.sql (100%)
 rename fail3.sql => test/fail3.sql (100%)
 rename fail4.sql => test/fail4.sql (100%)
 rename fail5.sql => test/fail5.sql (100%)
 rename ok1.sql => test/ok1.sql (100%)
 rename ok10.sql => test/ok10.sql (100%)
 rename ok2.sql => test/ok2.sql (100%)
 rename ok3.sql => test/ok3.sql (100%)
 rename ok4.sql => test/ok4.sql (100%)
 rename ok5.sql => test/ok5.sql (100%)
 rename ok6.sql => test/ok6.sql (100%)
 rename ok7.sql => test/ok7.sql (100%)
 rename ok8.sql => test/ok8.sql (100%)
 rename ok9.sql => test/ok9.sql (100%)
 rename test-fail.sh => test/test-fail.sh (55%)
 rename test-ok.sh => test/test-ok.sh (56%)
 rename tst-create-db.sql => test/tst-create-db.sql (100%)
 rename tst-create-table.sql => test/tst-create-table.sql (100%)
 rename tst-delete.sql => test/tst-delete.sql (100%)
 rename tst-drop-db.sql => test/tst-drop-db.sql (100%)
 rename tst-drop-table.sql => test/tst-drop-table.sql (100%)
 rename tst-insert.sql => test/tst-insert.sql (100%)
 rename xfail2.sql => test/xfail2.sql (100%)

diff --git a/.gitignore b/.gitignore
index f8347a8..2dbe212 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,4 @@ libsqlpars-uninstalled.pc
 libsqlpars.pc
 sqlpars-config.h*
 
+build-aux/
diff --git a/Makefile.am b/Makefile.am
index c8cdcfa..272400d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,34 +12,34 @@ pkgconfig_DATA = libsqlpars.pc
 # noinst_PROGRAMS = $(TESTS)
 EXTRA_DIST = sql.y sql.l \
 	pscan.js \
-	test-ok.sh test-fail.sh \
-	fail1.sql \
-	fail3.sql \
-	fail4.sql \
-	fail5.sql \
-	xfail2.sql \
-	ok1.sql \
-	ok2.sql \
-	ok3.sql \
-	ok4.sql \
-	ok5.sql \
-	ok6.sql \
-	ok7.sql \
-	ok8.sql \
-	ok9.sql \
-	ok10.sql
+	test/test-ok.sh test/test-fail.sh \
+	test/fail1.sql \
+	test/fail3.sql \
+	test/fail4.sql \
+	test/fail5.sql \
+	test/xfail2.sql \
+	test/ok1.sql \
+	test/ok2.sql \
+	test/ok3.sql \
+	test/ok4.sql \
+	test/ok5.sql \
+	test/ok6.sql \
+	test/ok7.sql \
+	test/ok8.sql \
+	test/ok9.sql \
+	test/ok10.sql
 
-sql_SOURCES = exec.c lib.c main.c sql-parser.h yyl.h
+sql_SOURCES = source/exec.c source/lib.c source/main.c source/sql-parser.h source/yyl.h
 sql_LDADD = @JANSSON_LIBS@
-nodist_sql_SOURCES = sql.c sql.tab.c sql.tab.h sql.lex.h
+nodist_sql_SOURCES = source/sql.c source/sql.tab.c source/sql.tab.h source/sql.lex.h
 
 BUILT_SOURCES = $(nodist_sql_SOURCES)
 CLEANFILES = $(nodist_sql_SOURCES) sql.output
 
-sql.tab.c sql.tab.h:   sql.y Makefile
-	${BISON} -vd $<
+source/sql.tab.c source/sql.tab.h:   source/sql.y Makefile
+	${BISON} -o $@ -vd $<
 
-sql.c sql.lex.h: sql.l Makefile
+source/sql.c source/sql.lex.h: source/sql.l Makefile
 	${LEX} -o $@ $<
 
 TESTS = test-ok.sh test-fail.sh
diff --git a/configure.ac b/configure.ac
index 33e94a1..ec93ac6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,10 +21,10 @@ dnl make the compilation flags quiet unless V=1 is used
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 AC_PREREQ(2.60)
-AC_CONFIG_SRCDIR([exec.c])
+AC_CONFIG_SRCDIR([source/exec.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([build-aux/m4])
-AC_CONFIG_HEADERS([sqlpars-config.h])
+AC_CONFIG_HEADERS([source/sqlpars-config.h])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 
 LIBSQLPARS_MAJOR_VERSION=libsqlpars_major_version
diff --git a/source/.dirstamp b/source/.dirstamp
new file mode 100644
index 0000000..e69de29
diff --git a/exec.c b/source/exec.c
similarity index 100%
rename from exec.c
rename to source/exec.c
diff --git a/lib.c b/source/lib.c
similarity index 100%
rename from lib.c
rename to source/lib.c
diff --git a/main.c b/source/main.c
similarity index 96%
rename from main.c
rename to source/main.c
index 8ea60fc..0cb4937 100644
--- a/main.c
+++ b/source/main.c
@@ -25,6 +25,7 @@ main(int ac, char **av)
 	abort();
 
   if(ac > 1) {
+    puts("wut?");
     if((in_f = fopen(av[1], "r")) == NULL) {
       perror(av[1]);
       exit(1);
@@ -41,7 +42,7 @@ main(int ac, char **av)
 
   psql_free(pstate);
 
-  if (!res && !yyerrno) {
+  if (!res) {
     printf("{\"result\":true}\n");
     return 0;
   } else {
diff --git a/sql-parser.h b/source/sql-parser.h
similarity index 100%
rename from sql-parser.h
rename to source/sql-parser.h
diff --git a/sql.l b/source/sql.l
similarity index 99%
rename from sql.l
rename to source/sql.l
index 4393384..5d3996a 100644
--- a/sql.l
+++ b/source/sql.l
@@ -18,7 +18,7 @@
 
 %option noyywrap nodefault yylineno case-insensitive reentrant
 %option bison-bridge bison-locations
-%option header-file="sql.lex.h"
+%option header-file="source/sql.lex.h"
 
 %{
 #include <stdarg.h>
diff --git a/sql.y b/source/sql.y
similarity index 99%
rename from sql.y
rename to source/sql.y
index 114760c..350b695 100644
--- a/sql.y
+++ b/source/sql.y
@@ -21,7 +21,6 @@
 #include <string.h>
 
 char *filename;
-int yyerrno;
 %}
 
 %define api.pure
@@ -32,7 +31,6 @@ int yyerrno;
 
 %code requires {
 extern char *filename;
-extern int yyerrno;
 
 #include "yyl.h"
 
@@ -329,11 +327,7 @@ void yyerror(YYLTYPE *, yyscan_t scanner, struct psql_state *pstate, const char
 void lyyerror(YYLTYPE t, const char *s, ...);
  %}
   /* free discarded tokens */
-%destructor {
-#if DEBUG
-printf ("free at %d %s\n",@$.first_line, $$); free($$);
-#endif
-} <strval>
+%destructor { printf ("free at %d %s\n",@$.first_line, $$); free($$); } <strval>
 
 %%
 
@@ -980,7 +974,7 @@ yyerror(YYLTYPE *t, yyscan_t scanner, struct psql_state *pstate, const char *s,
 	    t->last_line, t->last_column);
   vfprintf(stderr, s, ap);
   fprintf(stderr, "\n");
-  yyerrno = 1;
+
 }
 
 void
@@ -994,6 +988,5 @@ lyyerror(YYLTYPE t, const char *s, ...)
 	    t.last_line, t.last_column);
   vfprintf(stderr, s, ap);
   fprintf(stderr, "\n");
-  yyerrno = 1;
 }
 
diff --git a/yyl.h b/source/yyl.h
similarity index 100%
rename from yyl.h
rename to source/yyl.h
diff --git a/fail1.sql b/test/fail1.sql
similarity index 100%
rename from fail1.sql
rename to test/fail1.sql
diff --git a/fail3.sql b/test/fail3.sql
similarity index 100%
rename from fail3.sql
rename to test/fail3.sql
diff --git a/fail4.sql b/test/fail4.sql
similarity index 100%
rename from fail4.sql
rename to test/fail4.sql
diff --git a/fail5.sql b/test/fail5.sql
similarity index 100%
rename from fail5.sql
rename to test/fail5.sql
diff --git a/ok1.sql b/test/ok1.sql
similarity index 100%
rename from ok1.sql
rename to test/ok1.sql
diff --git a/ok10.sql b/test/ok10.sql
similarity index 100%
rename from ok10.sql
rename to test/ok10.sql
diff --git a/ok2.sql b/test/ok2.sql
similarity index 100%
rename from ok2.sql
rename to test/ok2.sql
diff --git a/ok3.sql b/test/ok3.sql
similarity index 100%
rename from ok3.sql
rename to test/ok3.sql
diff --git a/ok4.sql b/test/ok4.sql
similarity index 100%
rename from ok4.sql
rename to test/ok4.sql
diff --git a/ok5.sql b/test/ok5.sql
similarity index 100%
rename from ok5.sql
rename to test/ok5.sql
diff --git a/ok6.sql b/test/ok6.sql
similarity index 100%
rename from ok6.sql
rename to test/ok6.sql
diff --git a/ok7.sql b/test/ok7.sql
similarity index 100%
rename from ok7.sql
rename to test/ok7.sql
diff --git a/ok8.sql b/test/ok8.sql
similarity index 100%
rename from ok8.sql
rename to test/ok8.sql
diff --git a/ok9.sql b/test/ok9.sql
similarity index 100%
rename from ok9.sql
rename to test/ok9.sql
diff --git a/test-fail.sh b/test/test-fail.sh
similarity index 55%
rename from test-fail.sh
rename to test/test-fail.sh
index b8b2294..83f663a 100755
--- a/test-fail.sh
+++ b/test/test-fail.sh
@@ -1,8 +1,10 @@
 #!/bin/sh
 
-for testfn in $srcdir/fail*.sql
+export PATH=.:..:$PATH
+
+for testfn in fail*.sql
 do
-	cat $testfn | ./sql
+	cat $testfn | sql
 	if [ $? -ne 1 ]
 	then
 		echo "Failed on $testfn"
diff --git a/test-ok.sh b/test/test-ok.sh
similarity index 56%
rename from test-ok.sh
rename to test/test-ok.sh
index 8ab6e5d..93f0158 100755
--- a/test-ok.sh
+++ b/test/test-ok.sh
@@ -1,8 +1,10 @@
 #!/bin/sh
 
-for testfn in $srcdir/ok*.sql
+export PATH=.:..:$PATH
+
+for testfn in ok*.sql
 do
-	cat $testfn | ./sql
+	cat $testfn | sql
 	if [ $? -ne 0 ]
 	then
 		echo "Failed on $testfn"
diff --git a/tst-create-db.sql b/test/tst-create-db.sql
similarity index 100%
rename from tst-create-db.sql
rename to test/tst-create-db.sql
diff --git a/tst-create-table.sql b/test/tst-create-table.sql
similarity index 100%
rename from tst-create-table.sql
rename to test/tst-create-table.sql
diff --git a/tst-delete.sql b/test/tst-delete.sql
similarity index 100%
rename from tst-delete.sql
rename to test/tst-delete.sql
diff --git a/tst-drop-db.sql b/test/tst-drop-db.sql
similarity index 100%
rename from tst-drop-db.sql
rename to test/tst-drop-db.sql
diff --git a/tst-drop-table.sql b/test/tst-drop-table.sql
similarity index 100%
rename from tst-drop-table.sql
rename to test/tst-drop-table.sql
diff --git a/tst-insert.sql b/test/tst-insert.sql
similarity index 100%
rename from tst-insert.sql
rename to test/tst-insert.sql
diff --git a/xfail2.sql b/test/xfail2.sql
similarity index 100%
rename from xfail2.sql
rename to test/xfail2.sql