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
27 changes: 26 additions & 1 deletion awka/translate.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4426,6 +4426,25 @@ process_argv(int *argc, char *int_argv)
return argv;
}

char *
strrepl(char *src, char *find, char *rep)
{ /* src must have space to extend size, if rep is bigger than find */
char *p = strstr(src, find);
if (p)
{
int len = strlen(src)+strlen(rep)-strlen(find);
char rbuf[len];
memset(rbuf, 0, len);
if ( p >= src ) {
strncpy(rbuf, src, p-src);
rbuf[p-src]='\0';
strncat(rbuf, rep, strlen(rep));
strncat(rbuf, p+strlen(find), p+strlen(find)-src+strlen(src));
strcpy(src, rbuf);
strrepl(p+strlen(rep), find, rep);
}
}
}

/*
* translate
Expand Down Expand Up @@ -4662,7 +4681,13 @@ translate()
if (env_used == 1)
fprintf(outfp,"\n awka_env_used(1);\n\n");

fprintf(outfp," awka_init(argc, argv, \"%s\", \"%s\", \"%s\");\n", AWKAVERSION, DATE_STRING, awk_input_files);
/* use a temp version with an extra 100 chars to add a C style continuation \ char to the line endings of inline scripts */
char *tmp_files_str = malloc( (100 + strlen(awk_input_files)) * sizeof(char));
strcpy(tmp_files_str, awk_input_files);
strrepl(tmp_files_str, "\n", " \\\n");

fprintf(outfp," awka_init(argc, argv, \"%s\", \"%s\", \"%s\");\n", AWKAVERSION, DATE_STRING, tmp_files_str);
free(tmp_files_str);

if (split_max != 0 && split_max != INT_MAX)
{
Expand Down
4 changes: 2 additions & 2 deletions test/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ basic: msg \
backgsub beginexit begingetline bil bil2 bslash childin clobber \
clsflnam compare compl conflict convfmt cox delarprm divide dubois dynlj \
eiso eiso2 eiso3 eiso4 eofsplit extendedchars fldchg fldchgnf fnarydel \
fnrtest foronsplit fsbs fsfw fsrs fstabplus fun funstack fw gensub \
fnrtest foronsplit fsbs fsfw fsrs fstabplus fun funstack fw funcom gensub \
getline getline2 getlnbuf getnr2tb getnr2tm gsubtest hh intest \
intprec isarray len litoct longwrds mainexit math messages mmap8k \
negexp next nextfile nfldstr nfset nlfldsep nlstrina nofile \
Expand Down Expand Up @@ -114,7 +114,7 @@ prt1eval prtoeval rand retest sort splitrem splitwht subslash substr typeof zero
@$(CMP) [email protected] _$@ && rm -f _$@

amsal amsal3 amsal5 anchgsub arynocls asgext bil clsflnam eiso eiso2 eiso4 fldchg \
fldchgnf fsfw fsrs funstack fw getline2 getnr2tb getnr2tm nfset nlfldsep numindex \
fldchgnf fsfw fsrs funcom funstack fw getline2 getnr2tb getnr2tm nfset nlfldsep numindex \
parsecsv pdb_find_salt posix2 prdupval range reindops reparse rsnul1nl rswhite \
splitargv splitvar sprintfc swaplns tradanch ::
@echo $@
Expand Down
5 changes: 5 additions & 0 deletions test/funcom.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function f(x) {
#
return x
}
{ print $0, f($0) }
1 change: 1 addition & 0 deletions test/funcom.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
1 change: 1 addition & 0 deletions test/funcom.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a a
1 change: 0 additions & 1 deletion test/x.in

This file was deleted.

130 changes: 0 additions & 130 deletions test/x1

This file was deleted.

130 changes: 0 additions & 130 deletions test/x2

This file was deleted.

1 change: 0 additions & 1 deletion test/x3

This file was deleted.

8 changes: 0 additions & 8 deletions test/y.c

This file was deleted.

Empty file removed x.c
Empty file.