diff options
author | Nathan Angelacos <nangel@alpinelinux.org> | 2008-04-12 00:09:22 +0000 |
---|---|---|
committer | Nathan Angelacos <nangel@alpinelinux.org> | 2008-04-12 00:09:22 +0000 |
commit | eb2cf24032143f7a918d950dd9851291281d4138 (patch) | |
tree | b7442c942d83af01a23e350f896d40a3312e1f2d /src | |
parent | ed4b386b68d5a073444af04d92a3df0609cfd251 (diff) | |
download | haserl-eb2cf24032143f7a918d950dd9851291281d4138.tar.bz2 haserl-eb2cf24032143f7a918d950dd9851291281d4138.tar.xz |
0.9.24_RC2
Diffstat (limited to 'src')
-rw-r--r-- | src/common.c | 4 | ||||
-rw-r--r-- | src/h_bash.c | 26 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/common.c b/src/common.c index 3b02442..2ee4afb 100644 --- a/src/common.c +++ b/src/common.c @@ -4,8 +4,8 @@ * Copyright (c) 2005-2007 Nathan Angelacos (nangel@users.sourceforge.net) * * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 2, as published by the Free - * Software Foundation. + * the terms of the GNU General Public License, version 2, as published by the + * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or diff --git a/src/h_bash.c b/src/h_bash.c index 661b398..46efed8 100644 --- a/src/h_bash.c +++ b/src/h_bash.c @@ -292,6 +292,12 @@ bash_case (buffer_t * buf, char *str, size_t len) "echo 'error: missing expression for case'\nexit 99\n"; static char case_start[] = "case "; static char case_end[] = " in\n"; + /* + create a bogus case condition, nul+esc+eof, so nl+;;+nl + can be prepended to each when/otherwise/endcase, which + eliminates the need for ;; or <% ;; %> in the page source + */ + static char case_bogus[] = "\"\\000\\040\\004\") :\n"; if (len == 0) { @@ -312,7 +318,8 @@ bash_when (buffer_t * buf, char *str, size_t len) { static char err_msg[] = "echo 'error: missing expression for when'\nexit 99\n"; - static char elif_end[] = ")\n"; + static char when_start[] = "\n;;\n"; + static char when_end[] = ")\n"; if (len == 0) { @@ -320,8 +327,9 @@ bash_when (buffer_t * buf, char *str, size_t len) } else { + buffer_add (buf, when_start, strlen (when_start)); buffer_add (buf, str, len - 1); - buffer_add (buf, elif_end, strlen (elif_end)); + buffer_add (buf, when_end, strlen (when_end)); } } @@ -330,13 +338,16 @@ bash_when (buffer_t * buf, char *str, size_t len) void bash_otherwise (buffer_t * buf, char *str, size_t len) { - static char otherwise_start[] = "*)"; + static char otherwise_start[] = "\n;;\n"; + static char otherwise_start1[] = "*)"; static char otherwise_start2[] = "*) #"; static char otherwise_end[] = "\n"; + buffer_add (buf, otherwise_start, strlen (otherwise_start)); + if (len == 0) { - buffer_add (buf, otherwise_start, strlen (otherwise_start)); + buffer_add (buf, otherwise_start1, strlen (otherwise_start1)); } else { @@ -351,13 +362,16 @@ bash_otherwise (buffer_t * buf, char *str, size_t len) void bash_endcase (buffer_t * buf, char *str, size_t len) { - static char endcase_start[] = "esac"; + static char endcase_start[] = "\n;;\n"; + static char endcase_start1[] = "esac"; static char endcase_start2[] = "esac #"; static char endcase_end[] = "\n"; + buffer_add (buf, endcase_start, strlen (endcase_start)); + if (len == 0) { - buffer_add (buf, endcase_start, strlen (endcase_start)); + buffer_add (buf, endcase_start1, strlen (endcase_start1)); } else { |