From 4dd406007eaa5be6cc5d84dcd3c60d31863aaba9 Mon Sep 17 00:00:00 2001 From: Konstantin Kushnir Date: Sat, 25 May 2024 15:39:17 +0000 Subject: [PATCH] Disable creating writed object from Tcl --- .github/workflows/linux-build.yml | 6 ------ configure | 24 +++++++++--------------- configure.in | 24 +++++++++--------------- generic/writer.c | 4 +++- generic/writerCmd.c | 15 +++++++++++++-- 5 files changed, 34 insertions(+), 39 deletions(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 47417d5..f6ebc89 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -29,12 +29,6 @@ jobs: - compiler: gcc configure: " --disable-c-writer --disable-c-writerchannel --disable-c-vfs" description: "no writer, writerchannel, vfs" - - compiler: gcc - configure: "--disable-c-writerchannel --disable-c-vfs" - description: "no writerchannel, vfs" - - compiler: gcc - configure: "--disable-c-vfs" - description: "no vfs" name: build (${{ matrix.compiler }}, ${{ matrix.description }}) steps: - name: Checkout diff --git a/configure b/configure index cb52908..20fa538 100755 --- a/configure +++ b/configure @@ -9048,7 +9048,12 @@ else USECVFS="no" fi -if test ${USECWRITER} = yes; then +# c-writer / c-writerchan / c-vfs must be enabled together +if test ${USECWRITER} = yes \ + && test ${USECWRITERCHAN} = yes \ + && test ${USECVFS} = yes +then + printf "%s\n" "#define COOKFS_USECWRITER 1" >>confdefs.h COOKFS_PKGCONFIG_USECWRITER=1 @@ -9087,15 +9092,7 @@ if test ${USECWRITER} = yes; then -else - COOKFS_PKGCONFIG_USECWRITER=0 - # c-vfs requires c-writer - USECVFS="no" - # c-writerchan requires c-writer - USECWRITERCHAN="no" -fi -if test ${USECWRITERCHAN} = yes; then printf "%s\n" "#define COOKFS_USECWRITERCHAN 1" >>confdefs.h COOKFS_PKGCONFIG_USECWRITERCHAN=1 @@ -9134,13 +9131,7 @@ if test ${USECWRITERCHAN} = yes; then -else - COOKFS_PKGCONFIG_USECWRITERCHAN=0 - # c-vfs requires c-writerchannel - USECVFS="no" -fi -if test ${USECVFS} = yes; then printf "%s\n" "#define COOKFS_USECVFS 1" >>confdefs.h COOKFS_PKGCONFIG_USECVFS=1 @@ -9179,7 +9170,10 @@ if test ${USECVFS} = yes; then + else + COOKFS_PKGCONFIG_USECWRITER=0 + COOKFS_PKGCONFIG_USECWRITERCHAN=0 COOKFS_PKGCONFIG_USECVFS=0 fi diff --git a/configure.in b/configure.in index f6d67a5..1505439 100644 --- a/configure.in +++ b/configure.in @@ -223,33 +223,27 @@ else USECVFS="no" fi -if test ${USECWRITER} = yes; then +# c-writer / c-writerchan / c-vfs must be enabled together +if test ${USECWRITER} = yes \ + && test ${USECWRITERCHAN} = yes \ + && test ${USECVFS} = yes +then + AC_DEFINE(COOKFS_USECWRITER) COOKFS_PKGCONFIG_USECWRITER=1 TEA_ADD_SOURCES([writer.c writerCmd.c]) -else - COOKFS_PKGCONFIG_USECWRITER=0 - # c-vfs requires c-writer - USECVFS="no" - # c-writerchan requires c-writer - USECWRITERCHAN="no" -fi -if test ${USECWRITERCHAN} = yes; then AC_DEFINE(COOKFS_USECWRITERCHAN) COOKFS_PKGCONFIG_USECWRITERCHAN=1 TEA_ADD_SOURCES([writerchannel.c writerchannelIO.c]) -else - COOKFS_PKGCONFIG_USECWRITERCHAN=0 - # c-vfs requires c-writerchannel - USECVFS="no" -fi -if test ${USECVFS} = yes; then AC_DEFINE(COOKFS_USECVFS) COOKFS_PKGCONFIG_USECVFS=1 TEA_ADD_SOURCES([vfsDriver.c vfsVfs.c vfs.c vfsCmd.c]) + else + COOKFS_PKGCONFIG_USECWRITER=0 + COOKFS_PKGCONFIG_USECWRITERCHAN=0 COOKFS_PKGCONFIG_USECVFS=0 fi diff --git a/generic/writer.c b/generic/writer.c index 93ad091..d3d7a00 100644 --- a/generic/writer.c +++ b/generic/writer.c @@ -258,7 +258,8 @@ int Cookfs_WriterAddFile(Cookfs_Writer *w, Tcl_Obj *pathObj, // Check if a fatal error has occurred previously if (w->fatalError) { CookfsLog(printf("Cookfs_WriterAddFile: ERROR: writer in a fatal" - " error state")); + " error state: [%s]", + Tcl_GetString(Cookfs_WriterGetLastError(w)))); return TCL_ERROR; } @@ -960,6 +961,7 @@ generateSortKey: ; // empty statement fatalError: + CookfsLog(printf("Cookfs_WriterPurge: !!! SET FATAL ERROR STATE !!!")); w->fatalError = 1; result = TCL_ERROR; diff --git a/generic/writerCmd.c b/generic/writerCmd.c index 0920e96..9f5550d 100644 --- a/generic/writerCmd.c +++ b/generic/writerCmd.c @@ -8,7 +8,9 @@ #include "cookfs.h" -static Tcl_ObjCmdProc CookfsWriterCmd; +// Creating a writer object from Tcl is not supported as for now +// static Tcl_ObjCmdProc CookfsWriterCmd; + static Tcl_ObjCmdProc CookfsWriterHandlerCmd; static Tcl_CmdDeleteProc CookfsWriterHandlerCmdDeleteProc; @@ -16,12 +18,17 @@ int Cookfs_InitWriterCmd(Tcl_Interp *interp) { Tcl_CreateNamespace(interp, "::cookfs::c::writer", NULL, NULL); + // Creating a writer object from Tcl is not supported as for now + + /* Tcl_CreateObjCommand(interp, "::cookfs::c::writer", CookfsWriterCmd, (ClientData) NULL, NULL); Tcl_CreateAlias(interp, "::cookfs::writer", interp, "::cookfs::c::writer", 0, NULL); + */ + return TCL_OK; } @@ -47,6 +54,8 @@ Tcl_Obj *CookfsGetWriterObjectCmd(Tcl_Interp *interp, Cookfs_Writer *w) { return rc; } +// Creating a writer object from Tcl is not supported as for now +/* static int CookfsWriterCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { @@ -65,6 +74,7 @@ static int CookfsWriterCmd(ClientData clientData, Tcl_Interp *interp, return TCL_ERROR; } +*/ static void CookfsWriterHandlerCmdDeleteProc(ClientData clientData) { Cookfs_Writer *w = (Cookfs_Writer *)clientData; @@ -72,7 +82,6 @@ static void CookfsWriterHandlerCmdDeleteProc(ClientData clientData) { } static Cookfs_WriterHandleCommandProc CookfsWriterHandleCommandGetbuf; - // In headers: // Cookfs_WriterHandleCommandProc CookfsWriterHandleCommandWrite; @@ -99,6 +108,8 @@ static int CookfsWriterHandlerCmd(ClientData clientData, Tcl_Interp *interp, if (Tcl_GetIndexFromObj(interp, objv[1], commands, "command", 0, &command) != TCL_OK) { + CookfsLog(printf("CookfsWriterHandlerCmd: ERROR: unknown command [%s]", + Tcl_GetString(objv[1]))); return TCL_ERROR; }