mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-17 15:06:21 +00:00
minor refactoring, moved a function
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@178 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
768c80219b
commit
5b0989ac31
15
src/flow.c
15
src/flow.c
@ -86,9 +86,22 @@ void flow_forloop(struct for_loop *loop)
|
||||
// read condition, make copy, link to struct
|
||||
static void copy_condition(struct condition *condition, char terminator)
|
||||
{
|
||||
int err;
|
||||
|
||||
SKIPSPACE();
|
||||
DYNABUF_CLEAR(GlobalDynaBuf);
|
||||
Input_until_terminator(terminator);
|
||||
while ((GotByte != terminator) && (GotByte != CHAR_EOS)) {
|
||||
// append to GlobalDynaBuf and check for quotes
|
||||
DYNABUF_APPEND(GlobalDynaBuf, GotByte);
|
||||
if ((GotByte == '"') || (GotByte == '\'')) {
|
||||
err = Input_quoted_to_dynabuf(GotByte);
|
||||
// here GotByte changes, it might become CHAR_EOS
|
||||
DYNABUF_APPEND(GlobalDynaBuf, GotByte); // add closing quotes (or CHAR_EOS) as well
|
||||
if (err)
|
||||
break; // on error, exit before eating CHAR_EOS via GetByte()
|
||||
}
|
||||
GetByte();
|
||||
}
|
||||
DynaBuf_append(GlobalDynaBuf, CHAR_EOS); // ensure terminator
|
||||
condition->body = DynaBuf_get_copy(GlobalDynaBuf);
|
||||
}
|
||||
|
27
src/input.c
27
src/input.c
@ -427,33 +427,6 @@ char *Input_skip_or_store_block(boolean store)
|
||||
return DynaBuf_get_copy(GlobalDynaBuf);
|
||||
}
|
||||
|
||||
// Read bytes and add to GlobalDynaBuf until the given terminator (or CHAR_EOS)
|
||||
// is found. Act upon single and double quotes by entering (and leaving) quote
|
||||
// mode as needed (So the terminator does not terminate when inside quotes).
|
||||
// TODO - called by ONE fn to read loop conditions, terminator is either SOB or EOS,
|
||||
// so integrate this fn with its caller!
|
||||
void Input_until_terminator(char terminator)
|
||||
{
|
||||
int err;
|
||||
char byte = GotByte;
|
||||
|
||||
for (;;) {
|
||||
// Terminator? Exit. EndOfStatement? Exit.
|
||||
if ((byte == terminator) || (byte == CHAR_EOS))
|
||||
return;
|
||||
|
||||
// otherwise, append to GlobalDynaBuf and check for quotes
|
||||
DYNABUF_APPEND(GlobalDynaBuf, byte);
|
||||
if ((byte == '"') || (byte == '\'')) {
|
||||
err = Input_quoted_to_dynabuf(byte);
|
||||
DYNABUF_APPEND(GlobalDynaBuf, GotByte); // add terminating char (quote/EOS) as well
|
||||
if (err)
|
||||
return; // on error, exit now, before calling GetByte()
|
||||
}
|
||||
byte = GetByte();
|
||||
}
|
||||
}
|
||||
|
||||
// Append to GlobalDynaBuf while characters are legal for keywords.
|
||||
// Throws "missing string" error if none.
|
||||
// Returns number of characters added.
|
||||
|
@ -86,10 +86,7 @@ extern int Input_unescape_dynabuf(void);
|
||||
// After calling this function, GotByte holds '}'. Unless EOF was found first,
|
||||
// but then a serious error would have been thrown.
|
||||
extern char *Input_skip_or_store_block(boolean store);
|
||||
// Read bytes and add to GlobalDynaBuf until the given terminator (or CHAR_EOS)
|
||||
// is found. Act upon single and double quotes by entering (and leaving) quote
|
||||
// mode as needed (So the terminator does not terminate when inside quotes).
|
||||
extern void Input_until_terminator(char terminator);
|
||||
|
||||
// Append to GlobalDynaBuf while characters are legal for keywords.
|
||||
// Throws "missing string" error if none. Returns number of characters added.
|
||||
extern int Input_append_keyword_to_global_dynabuf(void);
|
||||
|
Loading…
Reference in New Issue
Block a user