Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ VERSION = $(shell date +%Y | sed s/0//).$(shell date +%m)

all: $(SUBDIRS) $(MDFILES)

libpbat: microgettext
pbat: microgettext libpbat libfasteval
pbatize tea modules: libpbat
po: pbat

$(SUBDIRS):
$(MAKE) -C $@

Expand Down Expand Up @@ -86,6 +91,10 @@ textfiles: $(TEXTFILES) $(MDFILES)
man/en_US/readme.tea : README.tpl
cat $< doc.ft | sed -e s,\{doc/,\{,g > $@

tea/tea$(EXEC_SUFFIX): tea

$(TEXTFILES) $(MDFILES): tea/tea$(EXEC_SUFFIX)

doc.md: README.tpl
cat README.tpl doc.ft > .README.tea
./tea/tea$(EXEC_SUFFIX) -e:utf-8 -o:md .README.tea .doc.md
Expand Down
19 changes: 17 additions & 2 deletions dump/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <math.h>
#include <float.h>
#include <fcntl.h>
#include <errno.h>

#ifdef WIN32
#include <io.h>
Expand Down Expand Up @@ -228,7 +229,21 @@ int dump_fd(int fd, struct dump_t* context)

spaces = (context->flags & DUMP_QUIET) ? "" : " ";

while ((count = read(fd, data, size))) {
while (1) {
count = read(fd, data, size);

if (count < 0) {
if (errno == EINTR)
continue;

fprintf(stderr, "dump: read error.\n");
free(chars);
free(data);
return -1;
}

if (count == 0)
break;

if (count < size) {
/* we reached eof and count is not a multiple of the
Expand Down Expand Up @@ -362,7 +377,7 @@ int main(int argc, char** argv)

flags &= ~ DUMP_DEFAULT;

while (*argv) {
while (**argv) {
switch (**argv) {

case 'a':
Expand Down
24 changes: 23 additions & 1 deletion femto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,29 @@ $(LIBS):
echo "lib_$@ = 0" >> femto-config.mk; \
fi;

$(FUNCTIONS):
WIN32:
@echo "Looking for : $@ ..."
@case "$(HOST)" in \
*mingw*|*cygwin*|*msys*) \
echo "fn_$@ = 1" >> femto-config.mk; \
echo " found";; \
*) \
echo "fn_$@ = 0" >> femto-config.mk; \
echo " none";; \
esac

MINGW_W64:
@echo "Looking for : $@ ..."
@case "$(HOST)" in \
*w64-mingw32*) \
echo "fn_$@ = 1" >> femto-config.mk; \
echo " found";; \
*) \
echo "fn_$@ = 0" >> femto-config.mk; \
echo " none";; \
esac

$(filter-out WIN32 MINGW_W64,$(FUNCTIONS)):
@echo "Looking for : $@ ..."
@sed -e 's,[@]fn[@],$@,g' -e 's,[@]fnp[@],$(shell echo $@ | sed -e 's,/,_,g' -e 's,[.],_,g'),g'< config.c.in > config.c
@if $(CC) -o femto-test.out config.c $(CFLAGS) $(LDFLAGS) -O0 -s 2> /dev/null; then \
Expand Down
4 changes: 3 additions & 1 deletion libpbat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ libpBat.a: $(OBJ_FILES)
clean:
rm -f $(OBJ_FILES) libpBat.a

.PHONY: all tea clean
bin: libpBat.a

.PHONY: all tea clean bin
10 changes: 5 additions & 5 deletions libpbat/cmdlib/pBat_String.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ LIBPBAT char* pBat_SkipAllBlanks(const char* lpCh)

LIBPBAT char* pBat_SearchChar(const char* lpCh, int cChar)
{
char* lpNxt;
const char* lpNxt;
char ok;
int i;

Expand Down Expand Up @@ -88,7 +88,7 @@ LIBPBAT char* pBat_SearchChar(const char* lpCh, int cChar)

LIBPBAT char* pBat_SearchLastChar(const char* lpCh, int cChar)
{
char *lpLastMatch=NULL,
const char *lpLastMatch = NULL,
*lpNxt;
char ok;
int i;
Expand Down Expand Up @@ -160,7 +160,7 @@ LIBPBAT char* pBat_GetNextNonEscaped(const char* lpCh)
LIBPBAT char* pBat_SearchToken(const char* restrict lpCh, const char* restrict lpDelims)
{

char* lpNxt;
const char* lpNxt;
char ok;
int i;

Expand Down Expand Up @@ -226,7 +226,7 @@ LIBPBAT char* pBat_SearchLastToken(const char* restrict lpCh, const char* restri
LIBPBAT char* pBat_SearchChar_OutQuotes(const char* lpCh, int cChar)
{

char *lpNxt,
const char *lpNxt,
*lpNextQuote;

int i;
Expand Down Expand Up @@ -332,7 +332,7 @@ LIBPBAT char* pBat_SearchChar_OutQuotes(const char* lpCh, int cChar)
LIBPBAT char* pBat_SearchToken_OutQuotes(const char* restrict lpCh, const char* restrict lpDelims)
{

char *lpNxt,
const char *lpNxt,
*lpNextQuote;

int i;
Expand Down
10 changes: 5 additions & 5 deletions libpbat/dir/pBat_Dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static FILELIST* pBat_AddMatch(char* name, FILELIST* files, struct match_args_t*

static int /* inline */ pBat_EndWithDirectoryMark(const char *dir)
{
char *c = NULL;
const char *c = NULL;

while (*dir)
c = dir++;
Expand Down Expand Up @@ -563,7 +563,7 @@ LIBPBAT LPFILELIST pBat_GetMatchFileList(char* lpPathMatch, int iFlag)
return file;
}

LIBPBAT int pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallBack)(FILELIST*))
LIBPBAT LPFILELIST pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallBack)(FILELIST*))
{
struct match_args_t args;
FILELIST* file;
Expand All @@ -581,7 +581,7 @@ LIBPBAT int pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallB

}

return (int)file;
return file;
}
#endif

Expand Down Expand Up @@ -632,7 +632,7 @@ LIBPBAT int pBat_EndWithPattern(const char* restrict match, const char* restrict

LIBPBAT int pBat_RegExpMatch(const char* restrict regexp, const char* restrict match)
{
char* next;
const char* next;
size_t size;

//printf("*** Comparing \"%s\" et \"%s\"\n", regexp, match);
Expand Down Expand Up @@ -751,7 +751,7 @@ LIBPBAT int pBat_EndWithCasePattern(const char* restrict match, const char* rest

LIBPBAT int pBat_RegExpCaseMatch(const char* restrict regexp, const char* restrict match)
{
char* next;
const char* next;
size_t size;

//printf("*** Comparing \"%s\" et \"%s\"\n", regexp, match);
Expand Down
4 changes: 2 additions & 2 deletions libpbat/dir/pBat_UnicodeDir.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ LIBPBAT LPFILELIST pBat_GetMatchFileList(char* lpPathMatch, int iFlag)
return file;
}

LIBPBAT int pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallBack)(FILELIST*))
LIBPBAT LPFILELIST pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallBack)(FILELIST*))
{
struct match_args_t args;
FILELIST* file;
Expand All @@ -613,7 +613,7 @@ LIBPBAT int pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallB

free(wpath);

return (int)file;
return file;
}

#endif
2 changes: 1 addition & 1 deletion libpbat/libpBat.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ typedef struct FILELIST {
LIBPBAT int pBat_RegExpMatch(const char* restrict lpRegExp, const char* restrict lpMatch);
LIBPBAT int pBat_RegExpCaseMatch(const char* restrict lpRegExp, const char* restrict lpMatch);
LIBPBAT LPFILELIST pBat_GetMatchFileList(char* lpPathMatch, int iFlag);
LIBPBAT int pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallBack)(FILELIST*));
LIBPBAT LPFILELIST pBat_GetMatchFileCallback(char* lpPathMatch, int iFlag, void(*pCallBack)(FILELIST*));
LIBPBAT int pBat_FreeFileList(LPFILELIST lpflFileList);
LIBPBAT int pBat_FormatFileSize (char* lpBuf, int iLenght, unsigned int iSize);
LIBPBAT int pBat_GetStaticPart(const char* lpPathMatch, char* lpStaticPart, size_t size);
Expand Down
7 changes: 4 additions & 3 deletions modules/batbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ OBJ_FILES = $(SOURCES:.c=.o) ../lib/pBat_Module.o

LDFLAGS += $(LIBPBAT_LD)
CFLAGS += $(LIBPBAT_INC) -I../lib/
MODULE_LDFLAGS = $(filter-out -static,$(LDFLAGS))

all: $(MODULE)

Expand All @@ -18,7 +19,7 @@ bin: $(MODULE)
clean:
rm -rf $(OBJ_FILES)

$(MODULE)$(EXEEXT): $(OBJ_FILES)
$(CC) -shared -fvisibility=hidden -o $(MODULE)$(EXEEXT) $(OBJ_FILES) $(LDFLAGS)
$(MODULE)$(EXEEXT): $(OBJ_FILES) ../../libpbat/libpBat.a
$(CC) -shared -fvisibility=hidden -o $(MODULE)$(EXEEXT) $(OBJ_FILES) $(MODULE_LDFLAGS)

.PHONY: all clean bin
.PHONY: all clean bin
5 changes: 3 additions & 2 deletions modules/sample/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ OBJ_FILES = $(SOURCES:.c=.o) ../lib/pBat_Module.o

LDFLAGS += $(LIBPBAT_LD)
CFLAGS += $(LIBPBAT_INC) -I../lib/
MODULE_LDFLAGS = $(filter-out -static,$(LDFLAGS))

all: sample
bin: sample
Expand All @@ -16,5 +17,5 @@ bin: sample
clean:
rm -rf $(OBJ_FILES)

sample: $(OBJ_FILES)
$(CC) -shared -fvisibility=hidden -o sample $(OBJ_FILES) $(LDFLAGS)
sample: $(OBJ_FILES) ../../libpbat/libpBat.a
$(CC) -shared -fvisibility=hidden -o sample $(OBJ_FILES) $(MODULE_LDFLAGS)
10 changes: 8 additions & 2 deletions pbat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ LDFLAGS += $(MICROGETTEXT_LD) $(LIBPBAT_LD) \
$(LIBMATHEVAL_LD) $(LIBCU8_LD) \
$(LPTHREAD_LD) $(LM_LD) $(LDL_LD)

ifneq ($(fn_WIN32),1)
ifeq ($(filter -lm,$(LDFLAGS)),)
LDFLAGS += -lm
endif
endif

ifeq ($(use_libcu8),1)
LDFLAGS += -lshlwapi
endif
Expand Down Expand Up @@ -56,7 +62,7 @@ SRC_FILES := \
./core/pBat_EsCache.c ./core/pBat_Pipe.c \
./command/pBat_Def.c ./command/pBat_Ask.c \
./command/pBat_Block.c ./command/pBat_Call.c ./command/pBat_Cd.c \
./command/pBat_Cls.c ./command/pBat_Color.c ./command/pBat_Copy.c \
./command/pBat_Choice.c ./command/pBat_Cls.c ./command/pBat_Color.c ./command/pBat_Copy.c \
./command/pBat_Del.c ./command/pBat_Dir.c ./command/pBat_Echo.c \
./command/pBat_Exit.c ./command/pBat_For.c ./command/pBat_Goto.c \
./command/pBat_Help.c ./command/pBat_If.c ./command/pBat_Mkdir.c \
Expand Down Expand Up @@ -84,7 +90,7 @@ clean:
bin: pbat
cp pbat$(EXEC_SUFFIX) $(BINDIR)/

pbat: $(OBJ_FILES)
pbat: $(OBJ_FILES) ../microgettext/libmicrogettext.a ../libpbat/libpBat.a ../libfasteval/libfasteval.a
$(CC) -o pbat$(EXEC_SUFFIX) $(OBJ_FILES) $(LDFLAGS)

.rc.o:
Expand Down
4 changes: 4 additions & 0 deletions pbat/command/pBat_Ask.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <stdarg.h>
#include <string.h>

#if !defined(WIN32)
#include <unistd.h>
#endif

#include <libpBat.h>

#include "pBat_Ask.h"
Expand Down
14 changes: 6 additions & 8 deletions pbat/command/pBat_Call.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,10 @@ int pBat_CmdCall(char* lpLine)
determine ``file'' extension, to choose wether it should
be executed inside or outside pBat */

if (pBat_GetFilePath(lpFullName, lpFile, sizeof(lpFullName)) == -1) {

pBat_ShowErrorMessage(PBAT_COMMAND_ERROR, lpFile, 0);

status = PBAT_COMMAND_ERROR;
goto error;
}
if (pBat_GetFilePath(lpFullName, lpFile, sizeof(lpFullName)) == -1) {
status = pBat_CmdCallExternal(lpFile, lpLine);
goto error;
}

pBat_SplitPath(lpFullName, NULL, NULL, NULL, lpExt);

Expand Down Expand Up @@ -269,6 +266,7 @@ int pBat_CmdCallFile(char* lpFile, char* lpFull, char* lpLabel, char* lpCmdLine)

ifIn.bEof=FALSE; /* the file is not at EOF */
ifIn.iPos=0; /* places the cursor at the origin */
ifIn.batch.curr = ifIn.batch.cmds;
snprintf(ifIn.lpFileName,
sizeof(ifIn.lpFileName),
"%s",
Expand Down Expand Up @@ -409,7 +407,7 @@ int pBat_CmdCallExternal(char* lpFile, char* lpCh)
pBat_EsCat(lpEsLine, " ");
pBat_EsCat(lpEsLine, lpCh);

/* Offer a free new expansion turn */
/* Offer a free new expansion turn */
pBat_ReplaceVars(lpEsLine);

bkInfo.lpBegin=pBat_EsToChar(lpEsLine);
Expand Down
Loading