mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
GLK: Don't use unsafe strcat and strcpy
This commit is contained in:
parent
b25335bd33
commit
93cdbbbf39
@ -921,7 +921,7 @@ static void gsc_status_print() {
|
||||
char score[64];
|
||||
|
||||
/* Make an attempt at a status line, starting with player location. */
|
||||
strcpy(buffer, "");
|
||||
buffer[0] = '\0';
|
||||
gsc_status_safe_strcat(buffer, sizeof(buffer), room);
|
||||
|
||||
/* Get the game's status line, or if none, format score. */
|
||||
@ -943,7 +943,7 @@ static void gsc_status_print() {
|
||||
g_vm->glk_put_string(" ]\n");
|
||||
|
||||
/* Save the details of the printed status buffer. */
|
||||
strcpy(current_status, buffer);
|
||||
Common::strcpy_s(current_status, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1147,8 +1147,9 @@ static void gsc_handle_font_tag(const sc_char *argument) {
|
||||
}
|
||||
|
||||
/* Copy and convert argument to all lowercase. */
|
||||
lower = (sc_char *)gsc_malloc(strlen(argument) + 1);
|
||||
strcpy(lower, argument);
|
||||
size_t ln = strlen(argument) + 1;
|
||||
lower = (sc_char *)gsc_malloc(ln);
|
||||
Common::strcpy_s(lower, ln, argument);
|
||||
for (index_ = 0; lower[index_] != '\0'; index_++)
|
||||
lower[index_] = g_vm->glk_char_to_lower(lower[index_]);
|
||||
|
||||
@ -2192,8 +2193,9 @@ static int gsc_command_escape(const char *string) {
|
||||
return FALSE;
|
||||
|
||||
/* Take a copy of the string, without any leading space or introducer. */
|
||||
string_copy = (char *)gsc_malloc(strlen(string + posn) + 1 - strlen("glk"));
|
||||
strcpy(string_copy, string + posn + strlen("glk"));
|
||||
size_t ln = strlen(string + posn) + 1 - 3 /*strlen("glk")*/;
|
||||
string_copy = (char *)gsc_malloc(ln);
|
||||
Common::strcpy_s(string_copy, ln, string + posn + 3 /* strlen("glk") */);
|
||||
|
||||
/*
|
||||
* Find the subcommand; the first word in the string copy. Find its end,
|
||||
|
@ -480,8 +480,9 @@ static void expr_eval_push_string(const sc_char *value) {
|
||||
sc_fatal("expr_eval_push_string: stack overflow\n");
|
||||
|
||||
/* Push a copy of value. */
|
||||
value_copy = (sc_char *)sc_malloc(strlen(value) + 1);
|
||||
strcpy(value_copy, value);
|
||||
size_t ln = strlen(value) + 1;
|
||||
value_copy = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(value_copy, ln, value);
|
||||
expr_eval_stack[expr_eval_stack_index].is_collectible = TRUE;
|
||||
expr_eval_stack[expr_eval_stack_index++].value.mutable_string = value_copy;
|
||||
}
|
||||
@ -1023,8 +1024,9 @@ static void expr_eval_action(CONTEXT, sc_int token) {
|
||||
* Resize text1 to be long enough for both, and concatenate, then
|
||||
* free text2, and push back the concatenation.
|
||||
*/
|
||||
text1 = (sc_char *)sc_realloc(text1, strlen(text1) + strlen(text2) + 1);
|
||||
strcat(text1, text2);
|
||||
size_t ln = strlen(text1) + strlen(text2) + 1;
|
||||
text1 = (sc_char *)sc_realloc(text1, ln);
|
||||
Common::strcat_s(text1, ln, text2);
|
||||
sc_free(text2);
|
||||
expr_eval_push_alloced_string(text1);
|
||||
break;
|
||||
|
@ -812,8 +812,9 @@ static void gs_string_copy(sc_char **to_string, const sc_char *from_string) {
|
||||
|
||||
/* Copy from_string if set, otherwise set to_string to NULL. */
|
||||
if (from_string) {
|
||||
*to_string = (sc_char *)sc_malloc(strlen(from_string) + 1);
|
||||
strcpy(*to_string, from_string);
|
||||
size_t ln = strlen(from_string) + 1;
|
||||
*to_string = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(*to_string, ln, from_string);
|
||||
} else
|
||||
*to_string = nullptr;
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ void memo_save_command(sc_memo_setref_t memento, const sc_char *command, sc_int
|
||||
}
|
||||
|
||||
/* Save the string into this slot, and normalize it for neatness. */
|
||||
strcpy(history->command, command);
|
||||
Common::strcpy_s(history->command, history->allocation, command);
|
||||
sc_normalize_string(history->command);
|
||||
history->sequence = memento->history_count + 1;
|
||||
history->timestamp = timestamp;
|
||||
|
@ -328,7 +328,7 @@ static sc_char *uip_new_word(const sc_char *word) {
|
||||
|
||||
/* Use the slot and update the pool cursor and free count. */
|
||||
shortword = uip_word_pool + index_;
|
||||
strcpy(shortword->word, word);
|
||||
Common::strcpy_s(shortword->word, word);
|
||||
shortword->is_in_use = TRUE;
|
||||
|
||||
uip_word_pool_cursor = index_;
|
||||
@ -341,7 +341,7 @@ static sc_char *uip_new_word(const sc_char *word) {
|
||||
|
||||
/* Fall back to less efficient allocations. */
|
||||
word_copy = (sc_char *)sc_malloc(required);
|
||||
strcpy(word_copy, word);
|
||||
Common::strcpy_s(word_copy, required, word);
|
||||
return word_copy;
|
||||
}
|
||||
}
|
||||
@ -1580,7 +1580,7 @@ static sc_char *uip_cleanse_string(const sc_char *original, sc_char *buffer, sc_
|
||||
*/
|
||||
required = strlen(original) + 1;
|
||||
string = (required < length) ? buffer : (sc_char *)sc_malloc(required);
|
||||
strcpy(string, original);
|
||||
Common::strcpy_s(string, required, original);
|
||||
|
||||
/* Trim, and return the string. */
|
||||
sc_trim_string(string);
|
||||
@ -1758,7 +1758,7 @@ sc_char *uip_replace_pronouns(sc_gameref_t game, const sc_char *string) {
|
||||
if (!buffer) {
|
||||
buffer_allocation = strlen(string) + 1;
|
||||
buffer = (sc_char *)sc_malloc(buffer_allocation);
|
||||
strcpy(buffer, string);
|
||||
Common::strcpy_s(buffer, buffer_allocation, string);
|
||||
current = buffer + (current - string);
|
||||
}
|
||||
|
||||
|
@ -238,17 +238,18 @@ static sc_char *pf_interpolate_vars(const sc_char *string, sc_var_setref_t vars)
|
||||
sc_char value[32];
|
||||
|
||||
sprintf(value, "%ld", vt_rvalue.integer);
|
||||
buffer = (sc_char *)sc_realloc(buffer, strlen(buffer) + strlen(value) + 1);
|
||||
strcat(buffer, value);
|
||||
size_t ln = strlen(buffer) + strlen(value) + 1;
|
||||
buffer = (sc_char *)sc_realloc(buffer, ln);
|
||||
Common::strcat_s(buffer, ln, value);
|
||||
break;
|
||||
}
|
||||
|
||||
case VAR_STRING:
|
||||
buffer = (sc_char *)sc_realloc(buffer,
|
||||
strlen(buffer) + strlen(vt_rvalue.string) + 1);
|
||||
strcat(buffer, vt_rvalue.string);
|
||||
case VAR_STRING: {
|
||||
size_t ln = strlen(buffer) + strlen(vt_rvalue.string) + 1;
|
||||
buffer = (sc_char *)sc_realloc(buffer, ln);
|
||||
Common::strcat_s(buffer, ln, vt_rvalue.string);
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
sc_fatal("pf_interpolate_vars: invalid variable type, %ld\n", type);
|
||||
}
|
||||
@ -266,8 +267,9 @@ static sc_char *pf_interpolate_vars(const sc_char *string, sc_var_setref_t vars)
|
||||
*/
|
||||
if (buffer) {
|
||||
if (is_interpolated) {
|
||||
buffer = (sc_char *)sc_realloc(buffer, strlen(buffer) + strlen(marker) + 1);
|
||||
strcat(buffer, marker);
|
||||
size_t ln = strlen(buffer) + strlen(marker) + 1;
|
||||
buffer = (sc_char *)sc_realloc(buffer, ln);
|
||||
Common::strcat_s(buffer, ln, marker);
|
||||
} else {
|
||||
sc_free(buffer);
|
||||
buffer = nullptr;
|
||||
@ -318,15 +320,16 @@ static sc_bool pf_replace_alr(const sc_char *string, sc_char **buffer, sc_int al
|
||||
* copy; else append to the existing buffer: basic copy-on-write.
|
||||
*/
|
||||
if (!buffer_) {
|
||||
buffer_ = (sc_char *)sc_malloc(cursor - marker + strlen(replacement) + 1);
|
||||
size_t ln = cursor - marker + strlen(replacement) + 1;
|
||||
buffer_ = (sc_char *)sc_malloc(ln);
|
||||
memcpy(buffer_, marker, cursor - marker);
|
||||
buffer_[cursor - marker] = NUL;
|
||||
strcat(buffer_, replacement);
|
||||
Common::strcat_s(buffer_, ln, replacement);
|
||||
} else {
|
||||
buffer_ = (sc_char *)sc_realloc(buffer_, strlen(buffer_) +
|
||||
cursor - marker + strlen(replacement) + 1);
|
||||
size_t ln = strlen(buffer_) + cursor - marker + strlen(replacement) + 1;
|
||||
buffer_ = (sc_char *)sc_realloc(buffer_, ln);
|
||||
strncat(buffer_, marker, cursor - marker);
|
||||
strcat(buffer_, replacement);
|
||||
Common::strcat_s(buffer_, ln, replacement);
|
||||
}
|
||||
|
||||
/* Advance over the original. */
|
||||
@ -335,8 +338,9 @@ static sc_bool pf_replace_alr(const sc_char *string, sc_char **buffer, sc_int al
|
||||
|
||||
/* If any pending text, append it to the buffer. */
|
||||
if (replacement) {
|
||||
buffer_ = (sc_char *)sc_realloc(buffer_, strlen(buffer_) + strlen(marker) + 1);
|
||||
strcat(buffer_, marker);
|
||||
size_t ln = strlen(buffer_) + strlen(marker) + 1;
|
||||
buffer_ = (sc_char *)sc_realloc(buffer_, ln);
|
||||
Common::strcat_s(buffer_, ln, marker);
|
||||
}
|
||||
|
||||
/* Write back buffer, and if replacement set, the buffer was altered. */
|
||||
@ -739,8 +743,9 @@ sc_char *pf_filter(const sc_char *string, sc_var_setref_t vars, sc_prop_setref_t
|
||||
|
||||
/* Our contract is to return an allocated string; copy if required. */
|
||||
if (!current) {
|
||||
current = (sc_char *)sc_malloc(strlen(string) + 1);
|
||||
strcpy(current, string);
|
||||
size_t ln = strlen(string) + 1;
|
||||
current = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(current, ln, string);
|
||||
}
|
||||
|
||||
return current;
|
||||
@ -763,8 +768,9 @@ sc_char *pf_filter_for_info(const sc_char *string, sc_var_setref_t vars) {
|
||||
|
||||
/* Our contract is to return an allocated string; copy if required. */
|
||||
if (!current) {
|
||||
current = (sc_char *)sc_malloc(strlen(string) + 1);
|
||||
strcpy(current, string);
|
||||
size_t ln = strlen(string) + 1;
|
||||
current = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(current, ln, string);
|
||||
}
|
||||
|
||||
return current;
|
||||
@ -845,7 +851,7 @@ static void pf_append_string(sc_filterref_t filter, const sc_char *string) {
|
||||
filter->buffer[0] = NUL;
|
||||
|
||||
/* Append the string to the buffer and extend length. */
|
||||
strcat(filter->buffer, string);
|
||||
Common::strcat_s(filter->buffer, filter->buffer_allocation, string);
|
||||
filter->buffer_length += length;
|
||||
}
|
||||
|
||||
@ -1020,7 +1026,7 @@ void pf_prepend_string(sc_filterref_t filter, const sc_char *string) {
|
||||
/* Take a copy of the current buffered string. */
|
||||
assert(filter->buffer[filter->buffer_length] == NUL);
|
||||
copy = (sc_char *)sc_malloc(filter->buffer_length + 1);
|
||||
strcpy(copy, filter->buffer);
|
||||
Common::strcpy_s(copy, filter->buffer_length + 1, filter->buffer);
|
||||
|
||||
/*
|
||||
* Now restart buffering with the input string passed in. Removing
|
||||
@ -1218,8 +1224,9 @@ sc_char *pf_escape(const sc_char *string) {
|
||||
escape = escape_buffer;
|
||||
}
|
||||
|
||||
buffer = (sc_char *)sc_realloc(buffer, strlen(buffer) + strlen(escape) + 1);
|
||||
strcat(buffer, escape);
|
||||
size_t ln = strlen(buffer) + strlen(escape) + 1;
|
||||
buffer = (sc_char *)sc_realloc(buffer, ln);
|
||||
Common::strcat_s(buffer, ln, escape);
|
||||
|
||||
/* Pass over character escaped and continue. */
|
||||
cursor++;
|
||||
@ -1354,7 +1361,7 @@ sc_char *pf_filter_input(const sc_char *string, sc_prop_setref_t bundle) {
|
||||
if (!buffer) {
|
||||
buffer_allocation = strlen(string) + 1;
|
||||
buffer = (sc_char *)sc_malloc(buffer_allocation);
|
||||
strcpy(buffer, string);
|
||||
Common::strcpy_s(buffer, buffer_allocation, string);
|
||||
current = buffer + (current - string);
|
||||
}
|
||||
|
||||
|
@ -187,8 +187,9 @@ static const sc_char *prop_dictionary_lookup(sc_prop_setref_t bundle, const sc_c
|
||||
}
|
||||
|
||||
/* Not found, so copy the string for dictionary insertion. */
|
||||
dict_string = (sc_char *)sc_malloc(strlen(string) + 1);
|
||||
strcpy(dict_string, string);
|
||||
size_t ln = strlen(string) + 1;
|
||||
dict_string = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(dict_string, ln, string);
|
||||
|
||||
/* Extend the dictionary if necessary. */
|
||||
bundle->dictionary = (sc_char **)prop_ensure_capacity(bundle->dictionary,
|
||||
|
@ -149,9 +149,9 @@ void res_handle_resource(sc_gameref_t game, const sc_char *partial_format,
|
||||
|
||||
/* Get soundfile property from the node supplied. */
|
||||
vt_full[partial_length].string = "SoundFile";
|
||||
strcpy(format, "S<-");
|
||||
strcat(format, partial_format);
|
||||
strcat(format, "s");
|
||||
Common::strcpy_s(format, partial_length + 5, "S<-");
|
||||
Common::strcat_s(format, partial_length + 5, partial_format);
|
||||
Common::strcat_s(format, partial_length + 5, "s");
|
||||
soundfile = prop_get_string(bundle, format, vt_full);
|
||||
|
||||
/* If a sound is defined, handle it. */
|
||||
@ -159,16 +159,16 @@ void res_handle_resource(sc_gameref_t game, const sc_char *partial_format,
|
||||
if (embedded) {
|
||||
/* Retrieve offset and length. */
|
||||
vt_full[partial_length].string = "SoundOffset";
|
||||
strcpy(format, "I<-");
|
||||
strcat(format, partial_format);
|
||||
strcat(format, "s");
|
||||
Common::strcpy_s(format, partial_length + 5, "I<-");
|
||||
Common::strcat_s(format, partial_length + 5, partial_format);
|
||||
Common::strcat_s(format, partial_length + 5, "s");
|
||||
soundoffset = prop_get_integer(bundle, format, vt_full)
|
||||
+ resource_start_offset;
|
||||
|
||||
vt_full[partial_length].string = "SoundLen";
|
||||
strcpy(format, "I<-");
|
||||
strcat(format, partial_format);
|
||||
strcat(format, "s");
|
||||
Common::strcpy_s(format, partial_length + 5, "I<-");
|
||||
Common::strcat_s(format, partial_length + 5, partial_format);
|
||||
Common::strcat_s(format, partial_length + 5, "s");
|
||||
soundlen = prop_get_integer(bundle, format, vt_full);
|
||||
} else {
|
||||
/* Coerce offset and length to zero. */
|
||||
@ -197,9 +197,9 @@ void res_handle_resource(sc_gameref_t game, const sc_char *partial_format,
|
||||
|
||||
/* Get graphicfile property from the node supplied. */
|
||||
vt_full[partial_length].string = "GraphicFile";
|
||||
strcpy(format, "S<-");
|
||||
strcat(format, partial_format);
|
||||
strcat(format, "s");
|
||||
Common::strcpy_s(format, partial_length + 5, "S<-");
|
||||
Common::strcat_s(format, partial_length + 5, partial_format);
|
||||
Common::strcat_s(format, partial_length + 5, "s");
|
||||
graphicfile = prop_get_string(bundle, format, vt_full);
|
||||
|
||||
/* If a graphic is defined, handle it. */
|
||||
@ -207,16 +207,16 @@ void res_handle_resource(sc_gameref_t game, const sc_char *partial_format,
|
||||
if (embedded) {
|
||||
/* Retrieve offset and length. */
|
||||
vt_full[partial_length].string = "GraphicOffset";
|
||||
strcpy(format, "I<-");
|
||||
strcat(format, partial_format);
|
||||
strcat(format, "s");
|
||||
Common::strcpy_s(format, partial_length + 5, "I<-");
|
||||
Common::strcat_s(format, partial_length + 5, partial_format);
|
||||
Common::strcat_s(format, partial_length + 5, "s");
|
||||
graphicoffset = prop_get_integer(bundle, format, vt_full)
|
||||
+ resource_start_offset;
|
||||
|
||||
vt_full[partial_length].string = "GraphicLen";
|
||||
strcpy(format, "I<-");
|
||||
strcat(format, partial_format);
|
||||
strcat(format, "s");
|
||||
Common::strcpy_s(format, partial_length + 5, "I<-");
|
||||
Common::strcat_s(format, partial_length + 5, partial_format);
|
||||
Common::strcat_s(format, partial_length + 5, "s");
|
||||
graphiclen = prop_get_integer(bundle, format, vt_full);
|
||||
} else {
|
||||
/* Coerce offset and length to zero. */
|
||||
@ -267,8 +267,9 @@ void res_sync_resources(sc_gameref_t game) {
|
||||
name = game->requested_sound.name;
|
||||
is_looping = !strcmp(name + strlen(name) - 2, "##");
|
||||
|
||||
clean_name = (sc_char *)sc_malloc(strlen(name) + 1);
|
||||
strcpy(clean_name, name);
|
||||
size_t ln = strlen(name) + 1;
|
||||
clean_name = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(clean_name, ln, name);
|
||||
if (is_looping)
|
||||
clean_name[strlen(clean_name) - 2] = NUL;
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ static sc_bool run_player_input(sc_gameref_t game) {
|
||||
}
|
||||
|
||||
/* Make the last element the current input element. */
|
||||
strcpy(line_element, prior_element);
|
||||
Common::strcpy_s(line_element, prior_element);
|
||||
} else {
|
||||
sc_int length, extent;
|
||||
|
||||
@ -1205,7 +1205,7 @@ static sc_bool run_player_input(sc_gameref_t game) {
|
||||
* up as do_again set in the game, where it wasn't when we entered here.
|
||||
*/
|
||||
if (!game->do_again && !is_rerunning)
|
||||
strcpy(prior_element, line_element);
|
||||
Common::strcpy_s(prior_element, line_element);
|
||||
|
||||
/*
|
||||
* If this was a request to run a command from the history, copy that
|
||||
@ -1218,7 +1218,7 @@ static sc_bool run_player_input(sc_gameref_t game) {
|
||||
|
||||
redo_command = memo_find_command(memento, game->redo_sequence);
|
||||
if (redo_command)
|
||||
strcpy(prior_element, redo_command);
|
||||
Common::strcpy_s(prior_element, redo_command);
|
||||
else {
|
||||
sc_error("run_player_input: invalid redo sequence request\n");
|
||||
game->do_again = FALSE;
|
||||
|
@ -1033,16 +1033,17 @@ static sc_char *parse_read_multiline(CONTEXT) {
|
||||
|
||||
/* Take a simple copy of the first line. */
|
||||
R0FUNC0(parse_get_taf_string, line);
|
||||
multiline = (sc_char *)sc_malloc(strlen(line) + 1);
|
||||
strcpy(multiline, line);
|
||||
size_t ln = strlen(line) + 1;
|
||||
multiline = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(multiline, ln, line);
|
||||
|
||||
/* Now concatenate until separator found. */
|
||||
R0FUNC0(parse_get_taf_string, line);
|
||||
while (memcmp(line, separator, SEPARATOR_SIZE) != 0) {
|
||||
multiline = (sc_char *)sc_realloc(multiline,
|
||||
strlen(multiline) + strlen(line) + 2);
|
||||
strcat(multiline, "\n");
|
||||
strcat(multiline, line);
|
||||
ln = strlen(multiline) + strlen(line) + 2;
|
||||
multiline = (sc_char *)sc_realloc(multiline, ln);
|
||||
Common::strcat_s(multiline, ln, "\n");
|
||||
Common::strcat_s(multiline, ln, line);
|
||||
R0FUNC0(parse_get_taf_string, line);
|
||||
}
|
||||
|
||||
@ -1188,8 +1189,9 @@ static sc_int parse_get_v400_resource_offset(const sc_char *name,
|
||||
* Take a copy of the name, and remove any trailing "##" looping sound
|
||||
* indicator flag. Who thinks this junk up?
|
||||
*/
|
||||
clean_name = (sc_char *)sc_malloc(strlen(name) + 1);
|
||||
strcpy(clean_name, name);
|
||||
size_t ln = strlen(name) + 1;
|
||||
clean_name = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(clean_name, ln, name);
|
||||
if (strcmp(clean_name + strlen(clean_name) - 2, "##") == 0)
|
||||
clean_name[strlen(clean_name) - 2] = NUL;
|
||||
|
||||
@ -2006,10 +2008,11 @@ static void parse_fixup_v390(CONTEXT, const sc_char *fixup) {
|
||||
sc_char *restrmask;
|
||||
sc_int index_;
|
||||
|
||||
restrmask = (sc_char *)sc_malloc(2 * restriction_count);
|
||||
strcpy(restrmask, "#");
|
||||
size_t ln = 2 * restriction_count;
|
||||
restrmask = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(restrmask, ln, "#");
|
||||
for (index_ = 1; index_ < restriction_count; index_++)
|
||||
strcat(restrmask, "A#");
|
||||
Common::strcat_s(restrmask, ln, "A#");
|
||||
|
||||
vt_key.string = "RestrMask";
|
||||
parse_push_key(vt_key, PROP_KEY_STRING);
|
||||
@ -2754,10 +2757,11 @@ static void parse_fixup_v380(const sc_char *fixup) {
|
||||
sc_char *restrmask;
|
||||
sc_int index_;
|
||||
|
||||
restrmask = (sc_char *)sc_malloc(2 * restriction_count);
|
||||
strcpy(restrmask, "#");
|
||||
size_t ln = 2 * restriction_count;
|
||||
restrmask = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(restrmask, ln, "#");
|
||||
for (index_ = 1; index_ < restriction_count; index_++)
|
||||
strcat(restrmask, "A#");
|
||||
Common::strcat_s(restrmask, ln, "A#");
|
||||
|
||||
vt_key.string = "RestrMask";
|
||||
parse_push_key(vt_key, PROP_KEY_STRING);
|
||||
|
@ -670,8 +670,9 @@ static void task_run_change_variable_action(sc_gameref_t game,
|
||||
if (!expr_eval_string_expression(expr, vars, &mutable_string)) {
|
||||
sc_error("task_run_change_variable_action:"
|
||||
" invalid string expression, %s\n", expr);
|
||||
mutable_string = (sc_char *)sc_malloc(strlen("[expr error]") + 1);
|
||||
strcpy(mutable_string, "[expr error]");
|
||||
size_t ln = strlen("[expr error]") + 1;
|
||||
mutable_string = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(mutable_string, ln, "[expr error]");
|
||||
}
|
||||
if (task_trace) {
|
||||
sc_trace("Task: variable %ld (%s) = %s, %s\n",
|
||||
|
@ -305,12 +305,13 @@ void var_put(sc_var_setref_t vars, const sc_char *name, sc_int type, sc_vartype_
|
||||
var->value.integer = vt_value.integer;
|
||||
break;
|
||||
|
||||
case VAR_STRING:
|
||||
case VAR_STRING: {
|
||||
size_t ln = strlen(vt_value.string) + 1;
|
||||
/* Use mutable string instead of const string. */
|
||||
var->value.mutable_string = (sc_char *)sc_realloc(var->value.mutable_string,
|
||||
strlen(vt_value.string) + 1);
|
||||
strcpy(var->value.mutable_string, vt_value.string);
|
||||
var->value.mutable_string = (sc_char *)sc_realloc(var->value.mutable_string, ln);
|
||||
Common::strcpy_s(var->value.mutable_string, ln, vt_value.string);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
sc_fatal("var_put: invalid variable type, %ld\n", var->type);
|
||||
@ -350,16 +351,16 @@ static void var_append_temp(sc_var_setref_t vars, const sc_char *string) {
|
||||
/* Create a new temporary area and copy string. */
|
||||
new_sentence = TRUE;
|
||||
noted = 0;
|
||||
vars->temporary = (sc_char *)sc_malloc(strlen(string) + 1);
|
||||
strcpy(vars->temporary, string);
|
||||
size_t ln = strlen(string) + 1;
|
||||
vars->temporary = (sc_char *)sc_malloc(ln);
|
||||
Common::strcpy_s(vars->temporary, ln, string);
|
||||
} else {
|
||||
/* Append string to existing temporary. */
|
||||
new_sentence = (vars->temporary[0] == NUL);
|
||||
noted = strlen(vars->temporary);
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary,
|
||||
strlen(vars->temporary) +
|
||||
strlen(string) + 1);
|
||||
strcat(vars->temporary, string);
|
||||
size_t ln = strlen(vars->temporary) + strlen(string) + 1;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, ln);
|
||||
Common::strcat_s(vars->temporary, ln, string);
|
||||
}
|
||||
|
||||
if (new_sentence)
|
||||
@ -780,7 +781,7 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
|
||||
/* Clear any current temporary for appends. */
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, 1);
|
||||
strcpy(vars->temporary, "");
|
||||
vars->temporary[0] = '\0';
|
||||
|
||||
/* Write what's in the object into temporary. */
|
||||
var_list_in_object(game, vars->referenced_object);
|
||||
@ -835,17 +836,17 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
vt_key[2].string = "Prefix";
|
||||
prefix = prop_get_string(bundle, "S<-sis", vt_key);
|
||||
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, strlen(prefix) + 1);
|
||||
strcpy(vars->temporary, prefix);
|
||||
size_t ln = strlen(prefix) + 1;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, ln);
|
||||
Common::strcpy_s(vars->temporary, ln, prefix);
|
||||
|
||||
vt_key[2].string = "Short";
|
||||
objname = prop_get_string(bundle, "S<-sis", vt_key);
|
||||
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary,
|
||||
strlen(vars->temporary)
|
||||
+ strlen(objname) + 2);
|
||||
strcat(vars->temporary, " ");
|
||||
strcat(vars->temporary, objname);
|
||||
ln = strlen(vars->temporary) + strlen(objname) + 2;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, ln);
|
||||
Common::strcat_s(vars->temporary, ln, " ");
|
||||
Common::strcat_s(vars->temporary, ln, objname);
|
||||
|
||||
return var_return_string(vars->temporary, type, vt_rvalue);
|
||||
} else {
|
||||
@ -886,8 +887,9 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
sc_error("var_get_system: invalid state for obstate\n");
|
||||
return var_return_string("[Obstate unknown]", type, vt_rvalue);
|
||||
}
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, strlen(state) + 1);
|
||||
strcpy(vars->temporary, state);
|
||||
size_t ln = strlen(state) + 1;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, ln);
|
||||
Common::strcpy_s(vars->temporary, ln, state);
|
||||
sc_free(state);
|
||||
|
||||
/* Return temporary. */
|
||||
@ -952,7 +954,7 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
|
||||
/* Clear any current temporary for appends. */
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, 1);
|
||||
strcpy(vars->temporary, "");
|
||||
vars->temporary[0] = '\0';
|
||||
|
||||
/* Write what's on the object into temporary. */
|
||||
var_list_on_object(game, vars->referenced_object);
|
||||
@ -977,7 +979,7 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
|
||||
/* Clear any current temporary for appends. */
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, 1);
|
||||
strcpy(vars->temporary, "");
|
||||
vars->temporary[0] = '\0';
|
||||
|
||||
/* Write what's on/in the object into temporary. */
|
||||
var_list_onin_object(game, vars->referenced_object);
|
||||
@ -1063,8 +1065,9 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
sc_error("var_get_system: invalid state for state_\n");
|
||||
return var_return_string("[State_ unknown]", type, vt_rvalue);
|
||||
}
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, strlen(state) + 1);
|
||||
strcpy(vars->temporary, state);
|
||||
size_t ln = strlen(state) + 1;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, ln);
|
||||
Common::strcpy_s(vars->temporary, ln, state);
|
||||
sc_free(state);
|
||||
|
||||
/* Restore saved referenced object and return. */
|
||||
@ -1202,30 +1205,31 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
vt_key[2].string = "Prefix";
|
||||
prefix = prop_get_string(bundle, "S<-sis", vt_key);
|
||||
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, strlen(prefix) + 5);
|
||||
strcpy(vars->temporary, "");
|
||||
size_t temporary_ln = strlen(prefix) + 5;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, temporary_ln);
|
||||
vars->temporary[0] = '\0';
|
||||
|
||||
normalized = prefix;
|
||||
if (sc_compare_word(prefix, "a", 1)) {
|
||||
strcat(vars->temporary, "the");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, "the");
|
||||
normalized = prefix + 1;
|
||||
} else if (sc_compare_word(prefix, "an", 2)) {
|
||||
strcat(vars->temporary, "the");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, "the");
|
||||
normalized = prefix + 2;
|
||||
} else if (sc_compare_word(prefix, "the", 3)) {
|
||||
strcat(vars->temporary, "the");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, "the");
|
||||
normalized = prefix + 3;
|
||||
} else if (sc_compare_word(prefix, "some", 4)) {
|
||||
strcat(vars->temporary, "the");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, "the");
|
||||
normalized = prefix + 4;
|
||||
} else if (sc_strempty(prefix))
|
||||
strcat(vars->temporary, "the ");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, "the ");
|
||||
|
||||
if (!sc_strempty(normalized)) {
|
||||
strcat(vars->temporary, normalized);
|
||||
strcat(vars->temporary, " ");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, normalized);
|
||||
Common::strcat_s(vars->temporary, temporary_ln, " ");
|
||||
} else if (normalized > prefix)
|
||||
strcat(vars->temporary, " ");
|
||||
Common::strcat_s(vars->temporary, temporary_ln, " ");
|
||||
|
||||
vt_key[2].string = "Short";
|
||||
objname = prop_get_string(bundle, "S<-sis", vt_key);
|
||||
@ -1238,10 +1242,9 @@ static sc_bool var_get_system(sc_var_setref_t vars, const sc_char *name,
|
||||
else if (sc_compare_word(objname, "some", 4))
|
||||
objname += 4;
|
||||
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary,
|
||||
strlen(vars->temporary)
|
||||
+ strlen(objname) + 1);
|
||||
strcat(vars->temporary, objname);
|
||||
temporary_ln = strlen(vars->temporary) + strlen(objname) + 1;
|
||||
vars->temporary = (sc_char *)sc_realloc(vars->temporary, temporary_ln);
|
||||
Common::strcat_s(vars->temporary, temporary_ln, objname);
|
||||
|
||||
return var_return_string(vars->temporary, type, vt_rvalue);
|
||||
} else {
|
||||
@ -1546,8 +1549,9 @@ void var_set_ref_text(sc_var_setref_t vars, const sc_char *text) {
|
||||
assert(var_is_valid(vars));
|
||||
|
||||
/* Take a copy of the string, and retain it. */
|
||||
vars->referenced_text = (sc_char *)sc_realloc(vars->referenced_text, strlen(text) + 1);
|
||||
strcpy(vars->referenced_text, text);
|
||||
size_t ln = strlen(text) + 1;
|
||||
vars->referenced_text = (sc_char *)sc_realloc(vars->referenced_text, ln);
|
||||
Common::strcpy_s(vars->referenced_text, ln, text);
|
||||
}
|
||||
|
||||
|
||||
|
@ -874,7 +874,7 @@ static void read_line(genfile fd, const char *typestr)
|
||||
readln(fd, linebuffer, 80);
|
||||
if (linebuffer[0] == 0 && texteof(fd)) {
|
||||
unexpected_eof = 1;
|
||||
strcpy(linebuffer, ">End Of File<");
|
||||
Common::strcpy_s(linebuffer, ">End Of File<");
|
||||
} else chop_newline(linebuffer);
|
||||
linenum++;
|
||||
}
|
||||
|
@ -219,9 +219,9 @@ static word it_pronoun(int item, rbool ind_form)
|
||||
/* (In particular, proper nouns shouldn't have a "the") */
|
||||
static void theset(char *buff, int item) {
|
||||
if (it_proper(item))
|
||||
strcpy(buff, "");
|
||||
buff[0] = '\0';
|
||||
else
|
||||
strcpy(buff, "the ");
|
||||
Common::strcpy_s(buff, FILL_SIZE, "the ");
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +236,7 @@ static void num_name_func(parse_rec *obj_rec, char *fill_buff, word prev_adj)
|
||||
word w;
|
||||
|
||||
if (obj_rec == nullptr) {
|
||||
strcpy(fill_buff, "");
|
||||
fill_buff[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
@ -247,9 +247,9 @@ static void num_name_func(parse_rec *obj_rec, char *fill_buff, word prev_adj)
|
||||
|
||||
if (w == 0) {
|
||||
if (obj_rec->info == D_NUM) sprintf(fill_buff, "%ld", (long)obj_rec->num);
|
||||
else strcpy(fill_buff, "");
|
||||
else fill_buff[0] = '\0';
|
||||
#if 0
|
||||
strcpy(fill_buff, "that"); /* We can try and hope */
|
||||
Common::strcpy_s(fill_buff, FILL_SIZE, "that"); /* We can try and hope */
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -269,7 +269,7 @@ static word get_adj(parse_rec *obj_rec, char *buff) {
|
||||
if (obj_rec->adj != 0) w = obj_rec->adj;
|
||||
else w = it_adj(obj_rec->obj);
|
||||
|
||||
if (w == 0) strcpy(buff, "");
|
||||
if (w == 0) buff[0] = '\0';
|
||||
else {
|
||||
rstrncpy(buff, dict[w], FILL_SIZE);
|
||||
if (it_proper(obj_rec->obj)) buff[0] = toupper(buff[0]);
|
||||
@ -283,7 +283,7 @@ static word get_adj(parse_rec *obj_rec, char *buff) {
|
||||
#define d2buff(i) {rstrncpy(fill_buff,dict[i],FILL_SIZE);return 1;}
|
||||
#define num_name(obj_rec,jsa) {num_name_func(obj_rec,fill_buff,jsa);return 1;}
|
||||
/* jsa= Just seen adj */
|
||||
#define youme(mestr,youstr) {strcpy(fill_buff,irun_mode?mestr:youstr);\
|
||||
#define youme(mestr,youstr) {Common::strcpy_s(fill_buff,FILL_SIZE,irun_mode?mestr:youstr);\
|
||||
return 1;}
|
||||
|
||||
word just_seen_adj; /* This determines if we just saw $adjective$; if so,
|
||||
@ -345,15 +345,15 @@ static int wordcode_match(const char **pvarname, char *fill_buff,
|
||||
return 1;
|
||||
} else if (match_str(pvarname, "OPEN")) {
|
||||
hold_val = extract_number(pvarname, maxnoun, '$');
|
||||
strcpy(fill_buff, it_open(hold_val) ? "open" : "closed");
|
||||
Common::strcpy_s(fill_buff, FILL_SIZE, it_open(hold_val) ? "open" : "closed");
|
||||
return 1;
|
||||
} else if (match_str(pvarname, "ON")) {
|
||||
hold_val = extract_number(pvarname, maxnoun, '$');
|
||||
strcpy(fill_buff, it_on(hold_val) ? "on" : "off");
|
||||
Common::strcpy_s(fill_buff, FILL_SIZE, it_on(hold_val) ? "on" : "off");
|
||||
return 1;
|
||||
} else if (match_str(pvarname, "LOCKED")) {
|
||||
hold_val = extract_number(pvarname, maxnoun, '$');
|
||||
strcpy(fill_buff, it_locked(hold_val, 0) ? "locked" : "unlocked");
|
||||
Common::strcpy_s(fill_buff, FILL_SIZE, it_locked(hold_val, 0) ? "locked" : "unlocked");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ static word add0_dict(const char *s) {
|
||||
dict[i] = (dict[i] - dictstr) + newstr;
|
||||
dictstr = newstr;
|
||||
}
|
||||
strcpy(dictstr + dictstrptr, s); /* Copy word into memory */
|
||||
Common::strcpy_s(dictstr + dictstrptr, dictstrsize - dictstrptr, s); /* Copy word into memory */
|
||||
dict[dp] = dictstr + dictstrptr;
|
||||
dictstrptr = newptr;
|
||||
|
||||
@ -691,7 +691,7 @@ static void init0_dict(void)
|
||||
|
||||
dict = (char **)rmalloc(sizeof(char *));
|
||||
dictstr = (char *)rmalloc(DICT_GRAN);
|
||||
strcpy(dictstr, "any");
|
||||
Common::strcpy_s(dictstr, DICT_GRAN, "any");
|
||||
dict[0] = dictstr;
|
||||
|
||||
dictstrptr = 4; /* Point just after 'any' */
|
||||
|
@ -811,9 +811,9 @@ static char *build_position(word prep_, word name)
|
||||
leng = strlen(dict[prep_]) + strlen(dict[name]) + 6; /* includes final '\0' */
|
||||
s = (char *)rmalloc(leng * sizeof(char));
|
||||
|
||||
strcpy(s, dict[prep_]);
|
||||
strcat(s, " the ");
|
||||
strcat(s, dict[name]);
|
||||
Common::strcpy_s(s, leng, dict[prep_]);
|
||||
Common::strcat_s(s, leng, " the ");
|
||||
Common::strcat_s(s, leng, dict[name]);
|
||||
assert((int)strlen(s) + 1 == leng);
|
||||
return s;
|
||||
}
|
||||
|
@ -830,8 +830,9 @@ static void gagt_status_print() {
|
||||
|
||||
/* Save the details of the printed status buffer. */
|
||||
free(gagt_status_buffer_printed);
|
||||
gagt_status_buffer_printed = (char *)gagt_malloc(strlen(gagt_status_buffer) + 1);
|
||||
strcpy(gagt_status_buffer_printed, gagt_status_buffer);
|
||||
size_t ln = strlen(gagt_status_buffer) + 1;
|
||||
gagt_status_buffer_printed = (char *)gagt_malloc(ln);
|
||||
Common::strcpy_s(gagt_status_buffer_printed, ln, gagt_status_buffer);
|
||||
}
|
||||
|
||||
|
||||
@ -4523,8 +4524,9 @@ static int gagt_command_escape(const char *string) {
|
||||
return FALSE;
|
||||
|
||||
/* Take a copy of the string, without any leading space or introducer. */
|
||||
string_copy = (char *)gagt_malloc(strlen(string + posn) + 1 - strlen("glk"));
|
||||
strcpy(string_copy, string + posn + strlen("glk"));
|
||||
size_t ln = strlen(string + posn) + 1 - 3 /*strlen("glk")*/;
|
||||
string_copy = (char *)gagt_malloc(ln);
|
||||
Common::strcpy_s(string_copy, ln, string + posn + 3 /*strlen("glk")*/);
|
||||
|
||||
/*
|
||||
* Find the subcommand; the first word in the string copy. Find its end,
|
||||
|
@ -288,7 +288,7 @@ void debug() {
|
||||
para();
|
||||
do {
|
||||
output("ABUG> ");
|
||||
(void)readline(buf);
|
||||
(void)readline(buf, sizeof(buf));
|
||||
|
||||
lin = 1;
|
||||
c = buf[0];
|
||||
|
@ -159,7 +159,7 @@ Boolean confirm(MsgKind msgno) {
|
||||
it could be affirmative, but for now any input is NOT! */
|
||||
prmsg(msgno);
|
||||
|
||||
if (!readline(buf)) return TRUE;
|
||||
if (!readline(buf, sizeof(buf))) return TRUE;
|
||||
col = 1;
|
||||
|
||||
return (buf[0] == '\0');
|
||||
@ -173,7 +173,7 @@ void quit(CONTEXT) {
|
||||
col = 1;
|
||||
statusline();
|
||||
prmsg(M_QUITACTION);
|
||||
if (!readline(buf)) {
|
||||
if (!readline(buf, sizeof(buf))) {
|
||||
CALL1(terminate, 0)
|
||||
}
|
||||
|
||||
|
@ -59,14 +59,14 @@ void glkio_printf(const char *fmt, ...) {
|
||||
*/
|
||||
|
||||
/* 4f - length of user buffer should be used */
|
||||
Boolean readline(char usrbuf[]) {
|
||||
Boolean readline(char usrbuf[], size_t maxlen) {
|
||||
if (g_vm->_pendingLook) {
|
||||
g_vm->_pendingLook = false;
|
||||
glkio_printf("look\n");
|
||||
strcpy(usrbuf, "look");
|
||||
Common::strcpy_s(usrbuf, maxlen, "look");
|
||||
} else {
|
||||
event_t event;
|
||||
g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
|
||||
g_vm->glk_request_line_event(glkMainWin, usrbuf, maxlen, 0);
|
||||
|
||||
/* FIXME: buffer size should be infallible: all existing calls use 256 or
|
||||
80 character buffers, except parse which uses LISTLEN (currently 100)
|
||||
|
@ -44,7 +44,7 @@ void glkio_printf(const char *, ...);
|
||||
#define LINELENGTH 80
|
||||
#define HISTORYLENGTH 20
|
||||
|
||||
extern Boolean readline(char usrbuf[]);
|
||||
extern Boolean readline(char usrbuf[], size_t maxlen);
|
||||
|
||||
} // End of namespace Alan2
|
||||
} // End of namespace Glk
|
||||
|
@ -863,9 +863,9 @@ static void do_it(CONTEXT) {
|
||||
if (alt[i]->action != 0) {
|
||||
if (trcflg) {
|
||||
if (i == 0)
|
||||
strcpy(trace, "GLOBAL");
|
||||
Common::strcpy_s(trace, "GLOBAL");
|
||||
else if (i == 1)
|
||||
strcpy(trace, "in LOCATION");
|
||||
Common::strcpy_s(trace, "in LOCATION");
|
||||
else
|
||||
sprintf(trace, "in PARAMETER %d", i - 1);
|
||||
if (alt[i]->qual == (Aword)Q_BEFORE)
|
||||
@ -889,9 +889,9 @@ static void do_it(CONTEXT) {
|
||||
if (!done[i] && alt[i]->action != 0) {
|
||||
if (trcflg) {
|
||||
if (i == 0)
|
||||
strcpy(trace, "GLOBAL");
|
||||
Common::strcpy_s(trace, "GLOBAL");
|
||||
else if (i == 1)
|
||||
strcpy(trace, "in LOCATION");
|
||||
Common::strcpy_s(trace, "in LOCATION");
|
||||
else
|
||||
sprintf(trace, "in PARAMETER %d", i - 1);
|
||||
printf("\n<VERB %d, %s, Body:>\n", cur.vrb, trace);
|
||||
@ -910,9 +910,9 @@ static void do_it(CONTEXT) {
|
||||
if (!done[i] && alt[i]->action != 0) {
|
||||
if (trcflg) {
|
||||
if (i == 0)
|
||||
strcpy(trace, "GLOBAL");
|
||||
Common::strcpy_s(trace, "GLOBAL");
|
||||
else if (i == 1)
|
||||
strcpy(trace, "in LOCATION");
|
||||
Common::strcpy_s(trace, "in LOCATION");
|
||||
else
|
||||
sprintf(trace, "in PARAMETER %d", i - 1);
|
||||
printf("\n<VERB %d, %s (AFTER), Body:>\n", cur.vrb, trace);
|
||||
|
@ -86,11 +86,12 @@ static Boolean eol = TRUE; /* Looking at End of line? Yes, initially */
|
||||
|
||||
|
||||
static void unknown(CONTEXT, char token[]) {
|
||||
char *str = (char *)allocate((int)strlen(token) + 4);
|
||||
size_t ln = strlen(token) + 4;
|
||||
char *str = (char *)allocate((int)ln);
|
||||
|
||||
str[0] = '\'';
|
||||
strcpy(&str[1], token);
|
||||
strcat(str, "'?");
|
||||
Common::strcpy_s(&str[1], ln, token);
|
||||
Common::strcat_s(str, ln, "'?");
|
||||
output(str);
|
||||
free(str);
|
||||
eol = TRUE;
|
||||
@ -156,7 +157,7 @@ static void agetline(CONTEXT) {
|
||||
if (logflg)
|
||||
fprintf(logfil, "> ");
|
||||
|
||||
if (!readline(buf)) {
|
||||
if (!readline(buf, sizeof(buf))) {
|
||||
if (g_vm->shouldQuit())
|
||||
return;
|
||||
|
||||
@ -167,7 +168,7 @@ static void agetline(CONTEXT) {
|
||||
anyOutput = FALSE;
|
||||
if (logflg)
|
||||
fprintf(logfil, "%s\n", buf);
|
||||
strcpy(isobuf, buf);
|
||||
Common::strcpy_s(isobuf, buf);
|
||||
|
||||
token = gettoken(isobuf);
|
||||
if (token != nullptr && strcmp("debug", token) == 0 && header->debug) {
|
||||
|
@ -200,6 +200,7 @@ char *stringUpper(char str[]) { /* INOUT - ISO string to convert */
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/*----------------------------------------------------------------------
|
||||
toIso
|
||||
|
||||
@ -304,6 +305,7 @@ void toNative(char copy[], /* OUT - Mapped string */
|
||||
if (NATIVECHARSET != 0)
|
||||
fromIso(copy, copy);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // End of namespace Alan2
|
||||
} // End of namespace Glk
|
||||
|
@ -70,6 +70,7 @@ extern char toUpperCase(int c); /* IN - ISO character to convert */
|
||||
extern char *stringLower(char str[]); /* INOUT - ISO string to convert */
|
||||
extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */
|
||||
|
||||
#if 0
|
||||
/* ISO string conversion functions */
|
||||
extern void toIso(char copy[], /* OUT - Mapped string */
|
||||
char original[], /* IN - string to convert */
|
||||
@ -81,6 +82,7 @@ extern void fromIso(char copy[], /* OUT - Mapped string */
|
||||
extern void toNative(char copy[], /* OUT - Mapped string */
|
||||
char original[], /* IN - string to convert */
|
||||
int charset); /* IN - current character set */
|
||||
#endif
|
||||
|
||||
} // End of namespace Alan2
|
||||
} // End of namespace Glk
|
||||
|
@ -327,9 +327,10 @@ void schedule(Aword event, Aword where, Aword after) {
|
||||
Aptr concat(Aptr as1, Aptr as2) {
|
||||
char *s1 = (char *)fromAptr(as1);
|
||||
char *s2 = (char *)fromAptr(as2);
|
||||
char *result = (char *)allocate(strlen((char *)s1) + strlen((char *)s2) + 1);
|
||||
strcpy(result, s1);
|
||||
strcat(result, s2);
|
||||
size_t ln = strlen(s1) + strlen(s2) + 1;
|
||||
char *result = (char *)allocate(ln);
|
||||
Common::strcpy_s(result, ln, s1);
|
||||
Common::strcat_s(result, ln, s2);
|
||||
return toAptr(result);
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ bool GlkIO::readLine(CONTEXT, char *buffer, size_t maxLen) {
|
||||
// Return a "restore" command
|
||||
forcePrint("> ");
|
||||
forcePrint("restore\n");
|
||||
strcpy(buffer, "restore");
|
||||
Common::strcpy_s(buffer, maxLen, "restore");
|
||||
|
||||
} else if (readingCommands) {
|
||||
if (glk_get_line_stream(commandFile, buffer, maxLen) == 0) {
|
||||
|
@ -267,11 +267,11 @@ static void nonDevelopmentRunningDevelopmentStateGame(const byte version[]) {
|
||||
char errorMessage[200];
|
||||
char versionString[100];
|
||||
|
||||
strcpy(errorMessage, "Games generated by a development state compiler");
|
||||
Common::strcpy_s(errorMessage, "Games generated by a development state compiler");
|
||||
sprintf(versionString, "(this game is v%d.%d.%d%s)", version[0], version[1],
|
||||
version[2], decodeState(version[3]));
|
||||
strcat(errorMessage, versionString);
|
||||
strcat(errorMessage, "can only be run with a matching interpreter. Look for a game file generated with an alpha, beta or release state compiler.>\n");
|
||||
Common::strcat_s(errorMessage, versionString);
|
||||
Common::strcat_s(errorMessage, "can only be run with a matching interpreter. Look for a game file generated with an alpha, beta or release state compiler.>\n");
|
||||
apperr(errorMessage);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void getLine(CONTEXT) {
|
||||
LONG_JUMP_LABEL("forfeit")
|
||||
}
|
||||
|
||||
strcpy(isobuf, buf);
|
||||
Common::strcpy_s(isobuf, buf);
|
||||
token = gettoken(isobuf);
|
||||
if (token != nullptr) {
|
||||
if (strcmp("debug", token) == 0 && header->debug) {
|
||||
|
@ -208,6 +208,7 @@ int compareStrings(char *str1, char *str2) {
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
toIso
|
||||
@ -313,6 +314,8 @@ void toNative(char copy[], char original[], int charset) {
|
||||
fromIso(copy, copy);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*======================================================================*/
|
||||
char *baseNameStart(char *fullPathName) {
|
||||
|
@ -99,6 +99,7 @@ extern char *stringLower(char str[]); /* INOUT - ISO string to convert */
|
||||
extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */
|
||||
extern int compareStrings(char str1[], char str2[]); /* Case-insensitive compare */
|
||||
|
||||
#if 0
|
||||
/* ISO string conversion functions */
|
||||
extern void toIso(char copy[], /* OUT - Mapped string */
|
||||
char original[], /* IN - string to convert */
|
||||
@ -110,6 +111,7 @@ extern void fromIso(char copy[], /* OUT - Mapped string */
|
||||
extern void toNative(char copy[], /* OUT - Mapped string */
|
||||
char original[], /* IN - string to convert */
|
||||
int charset); /* IN - current character set */
|
||||
#endif
|
||||
|
||||
extern char *baseNameStart(char *fullPathName);
|
||||
|
||||
|
@ -176,7 +176,7 @@ void OOToposGame::afterPrompt() {
|
||||
|
||||
// WORKAROUND: Allow for the Apple 2 password in the DOS version
|
||||
if (!scumm_stricmp(_inputLine, "vug957a"))
|
||||
strcpy(_inputLine, "tse957x");
|
||||
Common::strcpy_s(_inputLine, "tse957x");
|
||||
|
||||
if (_currentRoom != _currentRoomCopy)
|
||||
_updateFlags |= UPDATE_GRAPHICS;
|
||||
|
@ -137,7 +137,7 @@ void TalismanGame::afterPrompt() {
|
||||
if (_redoLine == REDO_NONE && _flags[3])
|
||||
_redoLine = REDO_PROMPT;
|
||||
} else {
|
||||
strcpy(_inputLine, _savedAction.c_str());
|
||||
Common::strcpy_s(_inputLine, _savedAction.c_str());
|
||||
_savedAction.clear();
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ AddFontCode:
|
||||
bufferbreak = 0;
|
||||
bufferbreaklen = 0;
|
||||
#endif
|
||||
strcpy(pbuffer, "");
|
||||
pbuffer[0] = '\0';
|
||||
plen = 0;
|
||||
linebreak = 0;
|
||||
linebreaklen = 0;
|
||||
@ -435,7 +435,7 @@ AddFontCode:
|
||||
hugo_font(currentfont = lastfont);
|
||||
Printout(pbuffer, 0);
|
||||
lastfont = currentfont;
|
||||
strcpy(pbuffer, "");
|
||||
pbuffer[0] = '\0';
|
||||
linebreak = 0;
|
||||
linebreaklen = 0;
|
||||
thisline = 0;
|
||||
@ -573,7 +573,7 @@ unsigned int Hugo::Dict() {
|
||||
codeptr += 2; /* "(" */
|
||||
|
||||
if (MEM(codeptr)==PARSE_T || MEM(codeptr)==WORD_T)
|
||||
strcpy(line, GetWord(GetValue()));
|
||||
Common::strcpy_s(line, GetWord(GetValue()));
|
||||
else
|
||||
{
|
||||
/* Get the array address to read the to-be-
|
||||
@ -760,7 +760,7 @@ void Hugo::FileIO() {
|
||||
ioerror = 0;
|
||||
|
||||
/* Make sure the filename is legal, 8 alphanumeric characters or less */
|
||||
strcpy(line, GetWord(fnameval));
|
||||
Common::strcpy_s(line, GetWord(fnameval));
|
||||
if (strlen(line) > 8) goto LeaveFileIO;
|
||||
for (i=0; i<(int)strlen(line); i++)
|
||||
{
|
||||
@ -779,7 +779,7 @@ void Hugo::FileIO() {
|
||||
hugo_splitpath(program_path, drive, dir, fname, ext);
|
||||
hugo_makepath(fileiopath, drive, dir, GetWord(fnameval), "");
|
||||
#else
|
||||
strcpy(fileiopath, GetWord(fnameval));
|
||||
Common::strcpy_s(fileiopath, GetWord(fnameval));
|
||||
#endif
|
||||
|
||||
if (iotype==WRITEFILE_T) /* "writefile" */
|
||||
@ -863,7 +863,7 @@ void Hugo::Flushpbuffer() {
|
||||
pbuffer[strlen(pbuffer)] = (char)NO_NEWLINE;
|
||||
Printout(Ltrim(pbuffer), 0);
|
||||
currentpos = hugo_textwidth(pbuffer); /* -charwidth; */
|
||||
strcpy(pbuffer, "");
|
||||
pbuffer[0] = '\0';
|
||||
}
|
||||
|
||||
void Hugo::GetCommand() {
|
||||
@ -918,9 +918,9 @@ void Hugo::GetCommand() {
|
||||
hugo_getline(a);
|
||||
#endif
|
||||
during_player_input = false;
|
||||
strcpy(buffer, Rtrim(buffer));
|
||||
Common::strcpy_s(buffer, Rtrim(buffer));
|
||||
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
full = 1;
|
||||
remaining = 0;
|
||||
@ -1072,7 +1072,7 @@ void Hugo::InitGame() {
|
||||
if (_savegameSlot == -1) {
|
||||
#endif
|
||||
#if defined (DEBUGGER)
|
||||
for (i=0; i<MAXLOCALS; i++) strcpy(localname[i], "");
|
||||
for (i=0; i<MAXLOCALS; i++) localname[i][0] = '\0';
|
||||
window[VIEW_LOCALS].count = current_locals = 0;
|
||||
|
||||
PassLocals(0);
|
||||
@ -1103,7 +1103,7 @@ void Hugo::LoadGame() {
|
||||
if (!strcmp(gamefile, ""))
|
||||
{
|
||||
game = nullptr;
|
||||
strcpy(gamefile, "(no file)");
|
||||
Common::strcpy_s(gamefile, "(no file)");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -1303,15 +1303,15 @@ void Hugo::LoadGame() {
|
||||
|
||||
/* build punctuation string (additional user-specified punctuation) */
|
||||
synptr = 2;
|
||||
strcpy(punc_string, "");
|
||||
punc_string[0] = '\0';
|
||||
for (i=1; i<=syncount; i++)
|
||||
{
|
||||
defseg = syntable;
|
||||
if (Peek(synptr)==3) /* 3 = punctuation */
|
||||
{
|
||||
strcpy(line, GetWord(PeekWord(synptr+1)));
|
||||
Common::strcpy_s(line, GetWord(PeekWord(synptr+1)));
|
||||
if (strlen(line) + strlen(punc_string) > 63) break;
|
||||
strcat(punc_string, line);
|
||||
Common::strcat_s(punc_string, line);
|
||||
}
|
||||
synptr+=5;
|
||||
}
|
||||
@ -1452,7 +1452,7 @@ const char *Hugo::PrintHex(long a) {
|
||||
static char hex[7];
|
||||
int h = 0;
|
||||
|
||||
strcpy(hex, "");
|
||||
hex[0] = '\0';
|
||||
|
||||
if (a < 0L) a = 0;
|
||||
|
||||
|
@ -398,7 +398,7 @@ int Hugo::MatchCommand() {
|
||||
|
||||
if (!strcmp(word[1], "~oops"))
|
||||
{
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
/* "oops" on its own */
|
||||
if (words==1 || !strcmp(oops, ""))
|
||||
@ -423,18 +423,18 @@ int Hugo::MatchCommand() {
|
||||
|
||||
/* Rebuild the corrected buffer */
|
||||
oopscount = 1;
|
||||
strcpy(line, word[2]);
|
||||
Common::strcpy_s(line, word[2]);
|
||||
for (i=1; i<=(int)strlen(errbuf); i++)
|
||||
{
|
||||
if (!strcmp(Mid(errbuf, i, strlen(oops)), oops))
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(buffer, errbuf);
|
||||
Common::strcpy_s(buffer, errbuf);
|
||||
buffer[i-1] = '\0';
|
||||
strcat(buffer, line);
|
||||
Common::strcat_s(buffer, line);
|
||||
|
||||
strcat(buffer, Right(errbuf, strlen(errbuf) - i - strlen(oops) + 1));
|
||||
Common::strcat_s(buffer, Right(errbuf, strlen(errbuf) - i - strlen(oops) + 1));
|
||||
|
||||
SeparateWords();
|
||||
if (!Parse())
|
||||
@ -588,7 +588,7 @@ MatchVerb:
|
||||
/* No match, ergo an invalid command */
|
||||
if (flag==0 && nextverb==true)
|
||||
{
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
ParseError(6, 0); /* "...doesn't make any sense..." */
|
||||
return 0;
|
||||
}
|
||||
@ -596,7 +596,7 @@ MatchVerb:
|
||||
/* No provision made for addressing objects (characters) */
|
||||
if (flag==0 || speaktoaddr==0)
|
||||
{
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
ParseError(2, 0); /* "Better start with a verb..." */
|
||||
return 0;
|
||||
}
|
||||
@ -651,7 +651,7 @@ GotVerb:
|
||||
|
||||
obj_match_state = 0;
|
||||
starts_with_verb = 1;
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
|
||||
if (Peek(grammaraddr)==XVERB_T) xverb = true;
|
||||
grammaraddr += 2 + numverbs * 2;
|
||||
@ -750,7 +750,7 @@ NextStructure:
|
||||
/* ...or if we reached the end without a sensible
|
||||
syntax matched:
|
||||
*/
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
/* "...doesn't make any sense..." */
|
||||
ParseError(6, 0);
|
||||
@ -822,7 +822,7 @@ bool Hugo::MatchObject(int *wordnum) {
|
||||
#ifdef DEBUG_PARSER
|
||||
Printout("MatchObject(): Entering");
|
||||
#endif
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
do /* starting at word #a */
|
||||
{
|
||||
@ -831,8 +831,8 @@ bool Hugo::MatchObject(int *wordnum) {
|
||||
*/
|
||||
if (word[*wordnum][0]!='~' && word[*wordnum][0]!='\0')
|
||||
{
|
||||
if (parseerr[0]!='\0') strcat(parseerr, " ");
|
||||
strcat(parseerr, word[*wordnum]);
|
||||
if (parseerr[0]!='\0') Common::strcat_s(parseerr, " ");
|
||||
Common::strcat_s(parseerr, word[*wordnum]);
|
||||
|
||||
flag = 0;
|
||||
for (i=0; i<objects; i++)
|
||||
@ -903,7 +903,7 @@ bool Hugo::MatchObject(int *wordnum) {
|
||||
/* If checking the xobject */
|
||||
if (obj_match_state==1)
|
||||
{
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
/* "...can't use multiple objects..."
|
||||
(as indirect objects) */
|
||||
ParseError(7, 0);
|
||||
@ -973,7 +973,7 @@ Clarify:
|
||||
/* If checking the xobject or addressing a command */
|
||||
if (obj_match_state==1 || speaking)
|
||||
{
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
/* "...can't use multiple objects..."
|
||||
(as indirect objects) */
|
||||
ParseError(7, 0);
|
||||
@ -1017,7 +1017,7 @@ Clarify:
|
||||
{
|
||||
if (!objcount && !speaking)
|
||||
{
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
ParseError(9, 0); /* "Nothing to (verb)..." */
|
||||
return false;
|
||||
}
|
||||
@ -1425,11 +1425,11 @@ Clarify:
|
||||
|
||||
RestoreTempArrays:
|
||||
/* Rebuild <buffer> and word[] array */
|
||||
strcpy(buffer, "");
|
||||
buffer[0] = '\0';
|
||||
for (i=1; i<=wtemp; i++)
|
||||
{
|
||||
strcat(buffer, GetWord(wdtemp[i]));
|
||||
strcat(buffer, " ");
|
||||
Common::strcat_s(buffer, GetWord(wdtemp[i]));
|
||||
Common::strcat_s(buffer, " ");
|
||||
}
|
||||
SeparateWords();
|
||||
|
||||
@ -1448,7 +1448,7 @@ RestoreTempArrays:
|
||||
i = Peek(grammaraddr);
|
||||
if (objcount>1 && i!=MULTI_T && i!=MULTIHELD_T && i!=MULTINOTHELD_T)
|
||||
{
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
/* "You can't...multiple objects." */
|
||||
ParseError(3, 0);
|
||||
return false;
|
||||
@ -1578,7 +1578,7 @@ RestoreTempArrays:
|
||||
else
|
||||
{
|
||||
/* No objects found */
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
ParseError(9, 0); /* "Nothing to (verb)..." */
|
||||
return false;
|
||||
}
|
||||
@ -1588,7 +1588,7 @@ RestoreTempArrays:
|
||||
/* Go back for the next object phrase */
|
||||
pobjcount = 0;
|
||||
mobjs = 0;
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
goto NextLoop;
|
||||
}
|
||||
@ -1771,7 +1771,7 @@ CheckWordorString:
|
||||
multicheck != MULTIHELD_T &&
|
||||
multicheck != MULTINOTHELD_T)
|
||||
{
|
||||
strcpy(parseerr, word[1]);
|
||||
Common::strcpy_s(parseerr, word[1]);
|
||||
/* "You can't...multiple objects." */
|
||||
ParseError(3, 0);
|
||||
return 2;
|
||||
@ -1968,14 +1968,14 @@ int Hugo::Parse() {
|
||||
period = FindWord(".");
|
||||
comma = FindWord(",");
|
||||
|
||||
strcpy(parsestr, ""); /* for storing any unknown string */
|
||||
parsestr[0] = '\0'; /* for storing any unknown string */
|
||||
parsed_number = 0; /* " " " parsed number */
|
||||
|
||||
for (i=1; i<=words; i++) /* find dictionary addresses */
|
||||
{
|
||||
if (word[i][0]=='\"' && foundstring==0)
|
||||
{
|
||||
strcpy(parsestr, word[i]);
|
||||
Common::strcpy_s(parsestr, word[i]);
|
||||
foundstring = 1;
|
||||
wd[i] = UNKNOWN_WORD;
|
||||
}
|
||||
@ -1992,7 +1992,7 @@ int Hugo::Parse() {
|
||||
#endif
|
||||
parsed_number = atoi(word[i]);
|
||||
if (parseerr[0]=='\0')
|
||||
strcpy(parseerr, word[i]);
|
||||
Common::strcpy_s(parseerr, word[i]);
|
||||
}
|
||||
|
||||
/* Otherwise it must be a dictionary entry */
|
||||
@ -2004,8 +2004,8 @@ int Hugo::Parse() {
|
||||
NotinDictionary:
|
||||
if (!notfound_word)
|
||||
{
|
||||
strcpy(parseerr, word[i]);
|
||||
strcpy(oops, word[i]);
|
||||
Common::strcpy_s(parseerr, word[i]);
|
||||
Common::strcpy_s(oops, word[i]);
|
||||
|
||||
notfound_word = i;
|
||||
}
|
||||
@ -2023,11 +2023,11 @@ NotinDictionary:
|
||||
|
||||
/* "...can't use the word..." */
|
||||
ParseError(1, 0);
|
||||
strcpy(errbuf, "");
|
||||
errbuf[0] = '\0';
|
||||
for (i=1; i<=words; i++)
|
||||
{
|
||||
strcat(errbuf, word[i]);
|
||||
if (i != words) strcat(errbuf, " ");
|
||||
Common::strcat_s(errbuf, word[i]);
|
||||
if (i != words) Common::strcat_s(errbuf, " ");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2058,19 +2058,19 @@ NotinDictionary:
|
||||
if (m)
|
||||
{
|
||||
if (m + (int)strlen(buffer) > 81)
|
||||
{strcpy(buffer, "");
|
||||
{buffer[0] = '\0';
|
||||
words = 0;
|
||||
ParseError(0, 0);
|
||||
return 0;}
|
||||
|
||||
for (k=words; k>i; k--)
|
||||
{
|
||||
strcpy(tempword, word[k]);
|
||||
Common::strcpy_s(tempword, word[k]);
|
||||
word[k] += m;
|
||||
strcpy(word[k], tempword);
|
||||
Common::strcpy_s(word[k], sizeof(buffer) - (word[k] - buffer), tempword);
|
||||
}
|
||||
}
|
||||
strcpy(word[i], GetWord(wd[i]));
|
||||
Common::strcpy_s(word[i], sizeof(buffer) - (word[i] - buffer), GetWord(wd[i]));
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
@ -2086,7 +2086,7 @@ NotinDictionary:
|
||||
{
|
||||
if (wd[i+1]==PeekWord(synptr+3))
|
||||
{
|
||||
strcat(word[i], word[i+1]);
|
||||
Common::strcat_s(word[i], sizeof(buffer) - (word[i] - buffer), word[i+1]);
|
||||
wd[i] = FindWord(word[i]);
|
||||
KillWord(i+1);
|
||||
}
|
||||
@ -2120,7 +2120,7 @@ NextSyn:
|
||||
|
||||
defseg = gameseg;
|
||||
|
||||
if (strcmp(word[1], "~oops")) strcpy(oops, "");
|
||||
if (strcmp(word[1], "~oops")) oops[0] = '\0';
|
||||
|
||||
if (words==0)
|
||||
{
|
||||
@ -2211,13 +2211,13 @@ void Hugo::ParseError(int e, int a) {
|
||||
{
|
||||
if (count==pobjcount)
|
||||
{
|
||||
if (count > 2) strcat(line, ",");
|
||||
strcat(line, " or ");
|
||||
if (count > 2) Common::strcat_s(line, ",");
|
||||
Common::strcat_s(line, " or ");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count != 1)
|
||||
strcat(line, ", ");
|
||||
Common::strcat_s(line, ", ");
|
||||
}
|
||||
if (GetProp(i, article, 1, 0))
|
||||
{
|
||||
@ -2225,18 +2225,18 @@ void Hugo::ParseError(int e, int a) {
|
||||
/* Don't use "a" or "an" in listing */
|
||||
/*
|
||||
if (!strcmp(w, "a") || !strcmp(w, "an"))
|
||||
strcat(line, "the ");
|
||||
Common::strcat_s(line, "the ");
|
||||
else
|
||||
sprintf(line+strlen(line), "%s ", w);
|
||||
*/
|
||||
/* We'll just use "the" */
|
||||
if (w) strcat(line, "the ");
|
||||
if (w) Common::strcat_s(line, "the ");
|
||||
}
|
||||
strcat(line, Name(i));
|
||||
Common::strcat_s(line, Name(i));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
strcat(line, "?");
|
||||
Common::strcat_s(line, "?");
|
||||
AP(line);
|
||||
break;
|
||||
}
|
||||
@ -2338,8 +2338,8 @@ void Hugo::SeparateWords() {
|
||||
}
|
||||
word[1] = buffer;
|
||||
|
||||
strcpy(a, buffer);
|
||||
strcpy(buffer, "");
|
||||
Common::strcpy_s(a, buffer);
|
||||
buffer[0] = '\0';
|
||||
|
||||
for (i=1; i<=(int)strlen(a); i++)
|
||||
{
|
||||
@ -2350,7 +2350,7 @@ void Hugo::SeparateWords() {
|
||||
|
||||
if (b[0]=='\"' && inquote==1)
|
||||
{
|
||||
strcpy(buffer+bloc, b);
|
||||
Common::strcpy_s(buffer+bloc, sizeof(buffer)-bloc, b);
|
||||
bloc++;
|
||||
inquote++;
|
||||
}
|
||||
@ -2362,12 +2362,12 @@ void Hugo::SeparateWords() {
|
||||
bloc++;
|
||||
if (++words > MAXWORDS) words = MAXWORDS;
|
||||
word[words] = buffer + bloc;
|
||||
strcpy(word[words], "");
|
||||
word[words][0] = '\0';
|
||||
}
|
||||
|
||||
if (b[0]=='\"' && inquote==0)
|
||||
{
|
||||
strcpy(buffer+bloc, b);
|
||||
Common::strcpy_s(buffer+bloc, sizeof(buffer)-bloc, b);
|
||||
bloc++;
|
||||
inquote = 1;
|
||||
}
|
||||
@ -2382,15 +2382,15 @@ void Hugo::SeparateWords() {
|
||||
if (++words > MAXWORDS) words = MAXWORDS;
|
||||
}
|
||||
word[words] = buffer + bloc;
|
||||
strcpy(word[words], b);
|
||||
Common::strcpy_s(word[words], sizeof(buffer)-bloc, b);
|
||||
bloc += strlen(b) + 1;
|
||||
if (++words > MAXWORDS) words = MAXWORDS;
|
||||
word[words] = buffer + bloc;
|
||||
strcpy(word[words], "");
|
||||
word[words][0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(buffer+bloc, b);
|
||||
Common::strcpy_s(buffer+bloc, sizeof(buffer)-bloc, b);
|
||||
bloc++;
|
||||
}
|
||||
}
|
||||
@ -2403,13 +2403,13 @@ void Hugo::SeparateWords() {
|
||||
/* Convert hours:minutes time to minutes only */
|
||||
if (strcspn(word[i], ":")!=strlen(word[i]) && strlen(word[i])<=5)
|
||||
{
|
||||
strcpy(w1, Left(word[i], strcspn(word[i], ":")));
|
||||
strcpy(w2, Right(word[i], strlen(word[i]) - strcspn(word[i], ":") - 1));
|
||||
Common::strcpy_s(w1, Left(word[i], strcspn(word[i], ":")));
|
||||
Common::strcpy_s(w2, Right(word[i], strlen(word[i]) - strcspn(word[i], ":") - 1));
|
||||
n1 = (short)atoi(w1);
|
||||
n2 = (short)atoi(w2);
|
||||
|
||||
if (!strcmp(Left(w2, 1), "0"))
|
||||
strcpy(w2, Right(w2, strlen(w2) - 1));
|
||||
Common::strcpy_s(w2, Right(w2, strlen(w2) - 1));
|
||||
|
||||
/* If this is indeed a hh:mm time, write it back
|
||||
as the modified word, storing the original hh:mm
|
||||
@ -2417,7 +2417,7 @@ void Hugo::SeparateWords() {
|
||||
*/
|
||||
if (!strcmp(w1, itoa((int)n1, temp, 10)) && !strcmp(w2, itoa((int)n2, temp, 10)) && (n1 > 0 && n1 < 25) && (n2 >= 0 && n2 < 60))
|
||||
{
|
||||
strcpy(parseerr, word[i]);
|
||||
Common::strcpy_s(parseerr, word[i]);
|
||||
itoa(n1 * 60 + n2, word[i], 10);
|
||||
}
|
||||
}
|
||||
@ -2538,10 +2538,10 @@ int Hugo::ValidObj(int obj) {
|
||||
{
|
||||
if (obj != (int)PeekWord(grammaraddr+2))
|
||||
{
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
if (GetProp(obj, article, 1, 0))
|
||||
strcpy(parseerr, "the ");
|
||||
strcat(parseerr, Name(obj));
|
||||
Common::strcpy_s(parseerr, "the ");
|
||||
Common::strcat_s(parseerr, Name(obj));
|
||||
|
||||
/* "...can't do that with..." */
|
||||
ParseError(12, obj);
|
||||
@ -2562,10 +2562,10 @@ int Hugo::ValidObj(int obj) {
|
||||
*/
|
||||
if (!TestAttribute(obj, attr, nattr))
|
||||
{
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
if (GetProp(obj, article, 1, 0))
|
||||
strcpy(parseerr, "the ");
|
||||
strcat(parseerr, Name(obj));
|
||||
Common::strcpy_s(parseerr, "the ");
|
||||
Common::strcat_s(parseerr, Name(obj));
|
||||
|
||||
/* "...can't do that with..." */
|
||||
ParseError(12, obj);
|
||||
|
@ -255,9 +255,9 @@ long Hugo::FindResource(const char *filename, const char *resname) {
|
||||
|
||||
resource_file = nullptr;
|
||||
|
||||
strcpy(loaded_filename, filename);
|
||||
strcpy(loaded_resname, resname);
|
||||
if (!strcmp(filename, "")) strcpy(loaded_filename, resname);
|
||||
Common::strcpy_s(loaded_filename, filename);
|
||||
Common::strcpy_s(loaded_resname, resname);
|
||||
if (!strcmp(filename, "")) Common::strcpy_s(loaded_filename, resname);
|
||||
|
||||
/* See if the file is supposed to be in a resourcefile to
|
||||
begin with
|
||||
@ -433,12 +433,12 @@ int Hugo::GetResourceParameters(char *filename, char *resname, int restype) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(filename, GetWord((unsigned int)f));
|
||||
Common::strcpy_s(filename, MAX_RES_PATH, GetWord((unsigned int)f));
|
||||
|
||||
if (MEM(codeptr++)!=EOL_T) /* two or more parameters */
|
||||
{
|
||||
strupr(filename);
|
||||
strcpy(resname, GetWord(GetValue()));
|
||||
Common::strcpy_s(resname, MAX_RES_PATH, GetWord(GetValue()));
|
||||
if (MEM(codeptr++)==COMMA_T)
|
||||
{
|
||||
extra_param = GetValue();
|
||||
@ -447,8 +447,8 @@ int Hugo::GetResourceParameters(char *filename, char *resname, int restype) {
|
||||
}
|
||||
else /* only one parameter */
|
||||
{
|
||||
strcpy(resname, filename);
|
||||
strcpy(filename, "");
|
||||
Common::strcpy_s(resname, MAX_RES_PATH, filename);
|
||||
filename[0] = '\0';
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -176,8 +176,8 @@ RestartDebugger:
|
||||
|
||||
Start:
|
||||
stack_depth = 0;
|
||||
strcpy(errbuf, "");
|
||||
strcpy(oops, "");
|
||||
errbuf[0] = '\0';
|
||||
oops[0] = '\0';
|
||||
|
||||
#if defined (GLK)
|
||||
// Handle any savegame selected directly from the ScummVM launcher
|
||||
@ -277,7 +277,7 @@ FreshInput:
|
||||
// Trigger a "look" command so that players will get some initial text
|
||||
// after loading a savegame directly from the launcher
|
||||
_savegameSlot = -1;
|
||||
strcpy(buffer, "look");
|
||||
Common::strcpy_s(buffer, "look");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -349,7 +349,7 @@ RecordedNewline:;
|
||||
|
||||
if (!strcmp(buffer, "") || buffer[0]=='.')
|
||||
{
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
/* "What?" */
|
||||
ParseError(0, 0);
|
||||
@ -412,13 +412,13 @@ Skipmc:;
|
||||
{
|
||||
if (parsestr[0]=='\"')
|
||||
{
|
||||
strcpy(parseerr, Right(parsestr, strlen(parsestr)-1));
|
||||
Common::strcpy_s(parseerr, Right(parsestr, strlen(parsestr)-1));
|
||||
if (parseerr[strlen(parseerr)-1]=='\"')
|
||||
parseerr[strlen(parseerr)-1] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
/* default actor */
|
||||
var[actor] = var[player];
|
||||
@ -487,7 +487,7 @@ NextPerform:
|
||||
trash passlocal[])
|
||||
*/
|
||||
if (parseerr[0]=='\0' && parsestr[0]=='\0')
|
||||
strcpy(parseerr, Name(objlist[i]));
|
||||
Common::strcpy_s(parseerr, Name(objlist[i]));
|
||||
|
||||
/* Set up arguments for Perform */
|
||||
passlocal[0] = var[verbroutine];
|
||||
@ -544,7 +544,7 @@ NextPerform:
|
||||
for (i=0; i<objcount; i++)
|
||||
{
|
||||
if (parseerr[0]=='\0' && parsestr[0]=='\0')
|
||||
strcpy(parseerr, Name(objlist[i]));
|
||||
Common::strcpy_s(parseerr, Name(objlist[i]));
|
||||
|
||||
if (ValidObj(objlist[i]) &&
|
||||
((objcount>1 && objlist[i]!=var[xobject]) || objcount==1))
|
||||
@ -830,7 +830,7 @@ PasstoBlock:
|
||||
void Hugo::RunInput() {
|
||||
int i;
|
||||
|
||||
strcpy(parseerr, "");
|
||||
parseerr[0] = '\0';
|
||||
|
||||
Flushpbuffer();
|
||||
|
||||
@ -842,7 +842,7 @@ void Hugo::RunInput() {
|
||||
if (debugger_collapsing) return;
|
||||
#endif
|
||||
|
||||
strcpy(buffer, Rtrim(strlwr(buffer)));
|
||||
Common::strcpy_s(buffer, Rtrim(strlwr(buffer)));
|
||||
|
||||
SeparateWords();
|
||||
|
||||
@ -854,10 +854,10 @@ void Hugo::RunInput() {
|
||||
if (wd[i]==UNKNOWN_WORD)
|
||||
{
|
||||
wd[i] = 0;
|
||||
strcpy(parseerr, word[i]);
|
||||
Common::strcpy_s(parseerr, word[i]);
|
||||
if (parseerr[0]=='\"')
|
||||
{
|
||||
strcpy(parseerr, Right(parseerr, strlen(parseerr)-1));
|
||||
Common::strcpy_s(parseerr, Right(parseerr, strlen(parseerr)-1));
|
||||
if (parseerr[strlen(parseerr)-1]=='\"')
|
||||
parseerr[strlen(parseerr)-1] = '\0';
|
||||
}
|
||||
@ -933,7 +933,7 @@ void Hugo::RunPrint() {
|
||||
|
||||
while (MEM(codeptr) != EOL_T)
|
||||
{
|
||||
strcpy(line, "");
|
||||
line[0] = '\0';
|
||||
|
||||
switch (MEM(codeptr))
|
||||
{
|
||||
@ -968,7 +968,7 @@ void Hugo::RunPrint() {
|
||||
a = (int)(ACTUAL_LINELENGTH() / ratio);
|
||||
}
|
||||
#endif
|
||||
strcpy(line, "");
|
||||
line[0] = '\0';
|
||||
l = 0;
|
||||
if (a*FIXEDCHARWIDTH >
|
||||
hugo_textwidth(pbuffer)+currentpos-hugo_charwidth(' '))
|
||||
@ -1031,7 +1031,7 @@ void Hugo::RunPrint() {
|
||||
a = GetValue();
|
||||
if (!number)
|
||||
{
|
||||
strcpy(line, GetWord(a));
|
||||
Common::strcpy_s(line, GetWord(a));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1061,7 +1061,7 @@ void Hugo::RunPrint() {
|
||||
if (MEM(codeptr)==SEMICOLON_T)
|
||||
{
|
||||
codeptr++;
|
||||
strcat(line, "\\;");
|
||||
Common::strcat_s(line, "\\;");
|
||||
}
|
||||
if (capital)
|
||||
{
|
||||
@ -1329,14 +1329,14 @@ void Hugo::RunRoutine(long addr) {
|
||||
/* If not object.property or an event */
|
||||
if (strchr(debug_line, '.')==nullptr && strstr(debug_line, "vent ")==nullptr)
|
||||
{
|
||||
strcat(debug_line, "(");
|
||||
Common::strcat_s(debug_line, "(");
|
||||
for (i=0; i<arguments_passed; i++)
|
||||
{
|
||||
sprintf(debug_line+strlen(debug_line), "%d", var[MAXGLOBALS+i]);
|
||||
if (i<arguments_passed-1)
|
||||
strcat(debug_line, ", ");
|
||||
Common::strcat_s(debug_line, ", ");
|
||||
}
|
||||
strcat(debug_line, ")");
|
||||
Common::strcat_s(debug_line, ")");
|
||||
}
|
||||
AddStringtoCodeWindow(debug_line);
|
||||
}
|
||||
@ -1556,7 +1556,7 @@ ProcessToken:
|
||||
/* If it doesn't exist, add it */
|
||||
if (i==current_locals)
|
||||
{
|
||||
strcpy(localname[current_locals], line);
|
||||
Common::strcpy_s(localname[current_locals], line);
|
||||
if (++current_locals==MAXLOCALS)
|
||||
current_locals--;
|
||||
window[VIEW_LOCALS].count = current_locals;
|
||||
@ -1576,10 +1576,10 @@ ProcessToken:
|
||||
case TEXTDATA_T: /* printed text from file */
|
||||
{
|
||||
textaddr = Peek(codeptr+1)*65536L+(long)PeekWord(codeptr+2);
|
||||
strcpy(line, GetText(textaddr));
|
||||
Common::strcpy_s(line, GetText(textaddr));
|
||||
codeptr += 4;
|
||||
if (Peek(codeptr)==SEMICOLON_T)
|
||||
{strcat(line, "\\;");
|
||||
{Common::strcat_s(line, "\\;");
|
||||
codeptr++;}
|
||||
if (capital)
|
||||
{line[0] = (char)toupper((int)line[0]);
|
||||
@ -2104,7 +2104,7 @@ ReturnfromRoutine:
|
||||
{
|
||||
sprintf(debug_line+strlen(debug_line), " to %s", RoutineName(old_currentroutine));
|
||||
}
|
||||
strcat(debug_line, ")");
|
||||
Common::strcat_s(debug_line, ")");
|
||||
AddStringtoCodeWindow(debug_line);
|
||||
AddStringtoCodeWindow("");
|
||||
|
||||
@ -2253,7 +2253,7 @@ int Hugo::RunString() {
|
||||
maxlen = GetValue();
|
||||
if (Peek(codeptr)==CLOSE_BRACKET_T) codeptr++;
|
||||
|
||||
strcpy(line, GetWord(dword));
|
||||
Common::strcpy_s(line, GetWord(dword));
|
||||
|
||||
defseg = arraytable;
|
||||
pos = 0;
|
||||
|
@ -137,12 +137,12 @@ GetNextWord:
|
||||
/* Have to (rather unfortunately) rebuild the entire
|
||||
input buffer and word array here
|
||||
*/
|
||||
strcpy(buffer, "");
|
||||
buffer[0] = '\0';
|
||||
t = 0;
|
||||
for (a=1; a<=(int)MAXWORDS; a++)
|
||||
{
|
||||
if ((unsigned short)wd[a]!=UNKNOWN_WORD)
|
||||
strcpy(buffer+t, GetWord(wd[a]));
|
||||
Common::strcpy_s(buffer+t, sizeof(buffer) - t, GetWord(wd[a]));
|
||||
else
|
||||
itoa(parsed_number, buffer+t, 10);
|
||||
word[a] = buffer + t;
|
||||
|
@ -83,7 +83,7 @@ Hugo::Hugo(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gam
|
||||
#endif
|
||||
{
|
||||
g_vm = this;
|
||||
strcpy(gamefile, "");
|
||||
gamefile[0] = '\0';
|
||||
|
||||
// heexpr
|
||||
Common::fill(&eval[0], &eval[MAX_EVAL_ELEMENTS], 0);
|
||||
@ -146,8 +146,8 @@ void Hugo::runGame() {
|
||||
|
||||
SetupDisplay();
|
||||
|
||||
strcpy(gamefile, getFilename().c_str());
|
||||
strcpy(pbuffer, "");
|
||||
Common::strcpy_s(gamefile, getFilename().c_str());
|
||||
pbuffer[0] = '\0';
|
||||
|
||||
ResourceArchive *res = new ResourceArchive();
|
||||
SearchMan.add("Resouces", res);
|
||||
|
@ -43,7 +43,7 @@ char *StringFunctions::Ltrim(char a[]) {
|
||||
int len = strlen(a);
|
||||
|
||||
temp = GetTempString();
|
||||
strcpy(temp, a);
|
||||
Common::strcpy_s(temp, sizeof(_tempString[0]), a);
|
||||
while (temp[0]==' ' || temp[0]=='\t')
|
||||
memmove(temp, temp+1, len + 1);
|
||||
return temp;
|
||||
@ -81,9 +81,9 @@ char *StringFunctions::Rtrim(char a[]) {
|
||||
int len;
|
||||
|
||||
temp = GetTempString();
|
||||
strcpy(temp, a);
|
||||
Common::strcpy_s(temp, sizeof(_tempString[0]), a);
|
||||
while (((len = strlen(temp))) && (temp[len-1]==' ' || temp[len-1]=='\t'))
|
||||
strcpy(temp, Left(temp, len-1));
|
||||
Common::strcpy_s(temp, sizeof(_tempString[0]), Left(temp, len-1));
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
@ -59,11 +59,11 @@ int check_light(int where) {
|
||||
|
||||
char *sentence_output(int index, int capital) {
|
||||
if (!strcmp(object[index]->article, "name")) {
|
||||
strcpy(temp_buffer, object[index]->inventory);
|
||||
Common::strcpy_s(temp_buffer, 1024, object[index]->inventory);
|
||||
} else {
|
||||
strcpy(temp_buffer, object[index]->definite);
|
||||
strcat(temp_buffer, " ");
|
||||
strcat(temp_buffer, object[index]->inventory);
|
||||
Common::strcpy_s(temp_buffer, 1024, object[index]->definite);
|
||||
Common::strcat_s(temp_buffer, 1024, " ");
|
||||
Common::strcat_s(temp_buffer, 1024, object[index]->inventory);
|
||||
}
|
||||
|
||||
if (capital)
|
||||
@ -88,18 +88,18 @@ char *is_output(int index, bool) {
|
||||
|
||||
char *sub_output(int index, int capital) {
|
||||
if (object[index]->attributes & PLURAL) {
|
||||
strcpy(temp_buffer, cstring_resolve("THEY_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("THEY_WORD")->value);
|
||||
} else {
|
||||
if (index == player) {
|
||||
strcpy(temp_buffer, cstring_resolve("YOU_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("YOU_WORD")->value);
|
||||
} else if (object[index]->attributes & ANIMATE) {
|
||||
if (object[index]->attributes & FEMALE) {
|
||||
strcpy(temp_buffer, cstring_resolve("SHE_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("SHE_WORD")->value);
|
||||
} else {
|
||||
strcpy(temp_buffer, cstring_resolve("HE_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("HE_WORD")->value);
|
||||
}
|
||||
} else {
|
||||
strcpy(temp_buffer, cstring_resolve("IT_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("IT_WORD")->value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,18 +111,18 @@ char *sub_output(int index, int capital) {
|
||||
|
||||
char *obj_output(int index, int capital) {
|
||||
if (object[index]->attributes & PLURAL) {
|
||||
strcpy(temp_buffer, cstring_resolve("THEM_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("THEM_WORD")->value);
|
||||
} else {
|
||||
if (index == player) {
|
||||
strcpy(temp_buffer, cstring_resolve("YOURSELF_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("YOURSELF_WORD")->value);
|
||||
} else if (object[index]->attributes & ANIMATE) {
|
||||
if (object[index]->attributes & FEMALE) {
|
||||
strcpy(temp_buffer, cstring_resolve("HER_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("HER_WORD")->value);
|
||||
} else {
|
||||
strcpy(temp_buffer, cstring_resolve("HIM_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("HIM_WORD")->value);
|
||||
}
|
||||
} else {
|
||||
strcpy(temp_buffer, cstring_resolve("IT_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("IT_WORD")->value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,9 +146,9 @@ char *it_output(int index, bool) {
|
||||
|
||||
char *that_output(int index, int capital) {
|
||||
if (object[index]->attributes & PLURAL) {
|
||||
strcpy(temp_buffer, cstring_resolve("THOSE_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("THOSE_WORD")->value);
|
||||
} else {
|
||||
strcpy(temp_buffer, cstring_resolve("THAT_WORD")->value);
|
||||
Common::strcpy_s(temp_buffer, 1024, cstring_resolve("THAT_WORD")->value);
|
||||
}
|
||||
|
||||
if (capital)
|
||||
@ -173,11 +173,11 @@ char *does_output(int index, bool) {
|
||||
|
||||
char *list_output(int index, int capital) {
|
||||
if (!strcmp(object[index]->article, "name")) {
|
||||
strcpy(temp_buffer, object[index]->inventory);
|
||||
Common::strcpy_s(temp_buffer, 1024, object[index]->inventory);
|
||||
} else {
|
||||
strcpy(temp_buffer, object[index]->article);
|
||||
strcat(temp_buffer, " ");
|
||||
strcat(temp_buffer, object[index]->inventory);
|
||||
Common::strcpy_s(temp_buffer, 1024, object[index]->article);
|
||||
Common::strcat_s(temp_buffer, 1024, " ");
|
||||
Common::strcat_s(temp_buffer, 1024, object[index]->inventory);
|
||||
}
|
||||
|
||||
if (capital)
|
||||
@ -187,7 +187,7 @@ char *list_output(int index, int capital) {
|
||||
}
|
||||
|
||||
char *plain_output(int index, int capital) {
|
||||
strcpy(temp_buffer, object[index]->inventory);
|
||||
Common::strcpy_s(temp_buffer, 1024, object[index]->inventory);
|
||||
|
||||
if (capital)
|
||||
temp_buffer[0] = toupper(temp_buffer[0]);
|
||||
@ -197,8 +197,8 @@ char *plain_output(int index, int capital) {
|
||||
|
||||
char *long_output(int index) {
|
||||
if (!strcmp(object[index]->described, "function")) {
|
||||
strcpy(function_name, "long_");
|
||||
strcat(function_name, object[index]->label);
|
||||
Common::strcpy_s(function_name, 1024, "long_");
|
||||
Common::strcat_s(function_name, 1024, object[index]->label);
|
||||
if (execute(function_name) == FALSE) {
|
||||
unkfunrun(function_name);
|
||||
}
|
||||
@ -241,8 +241,8 @@ void look_around() {
|
||||
object[HERE]->attributes &= ~1L;
|
||||
}
|
||||
|
||||
strcpy(function_name, "look_");
|
||||
strcat(function_name, object[HERE]->label);
|
||||
Common::strcpy_s(function_name, 81, "look_");
|
||||
Common::strcat_s(function_name, 81, object[HERE]->label);
|
||||
execute(function_name);
|
||||
|
||||
/* GIVE THE LOCATION THE ATTRIBUTES 'VISITED', 'KNOWN', AND 'MAPPED' NOW
|
||||
@ -253,8 +253,8 @@ void look_around() {
|
||||
|
||||
execute("+object_descriptions");
|
||||
|
||||
strcpy(function_name, "after_look_");
|
||||
strcat(function_name, object[HERE]->label);
|
||||
Common::strcpy_s(function_name, 81, "after_look_");
|
||||
Common::strcat_s(function_name, 81, object[HERE]->label);
|
||||
execute(function_name);
|
||||
|
||||
execute("+after_look");
|
||||
|
@ -307,7 +307,7 @@ void build_proxy() {
|
||||
/* LOOP THROUGH ALL THE PARAMETERS OF THE PROXY COMMAND
|
||||
AND BUILD THE MOVE TO BE ISSUED ON THE PLAYER'S BEHALF */
|
||||
for (index = 1; word[index] != nullptr; index++) {
|
||||
strcat(proxy_buffer, text_of_word(index));
|
||||
Common::strcat_s(proxy_buffer, 1024, text_of_word(index));
|
||||
}
|
||||
|
||||
for (index = 0; index < (int)strlen(proxy_buffer); index++) {
|
||||
@ -588,11 +588,11 @@ int execute(const char *funcname) {
|
||||
// infile REMAINS OPEN DURING THE ITERATION, ONLY NEEDS
|
||||
// OPENING THE FIRST TIME
|
||||
if (infile == nullptr) {
|
||||
strcpy(temp_buffer, data_directory);
|
||||
strcat(temp_buffer, prefix);
|
||||
strcat(temp_buffer, "-");
|
||||
strcat(temp_buffer, text_of_word(1));
|
||||
strcat(temp_buffer, ".csv");
|
||||
Common::strcpy_s(temp_buffer, 1024, data_directory);
|
||||
Common::strcat_s(temp_buffer, 1024, prefix);
|
||||
Common::strcat_s(temp_buffer, 1024, "-");
|
||||
Common::strcat_s(temp_buffer, 1024, text_of_word(1));
|
||||
Common::strcat_s(temp_buffer, 1024, ".csv");
|
||||
|
||||
infile = File::openForReading(temp_buffer);
|
||||
|
||||
@ -662,24 +662,24 @@ int execute(const char *funcname) {
|
||||
// infile REMAINS OPEN DURING THE ITERATION, ONLY NEEDS
|
||||
// OPENING THE FIRST TIME
|
||||
if (infile == nullptr) {
|
||||
strcpy(in_name, data_directory);
|
||||
strcat(in_name, prefix);
|
||||
strcat(in_name, "-");
|
||||
strcat(in_name, text_of_word(1));
|
||||
strcat(in_name, ".csv");
|
||||
Common::strcpy_s(in_name, data_directory);
|
||||
Common::strcat_s(in_name, prefix);
|
||||
Common::strcat_s(in_name, "-");
|
||||
Common::strcat_s(in_name, text_of_word(1));
|
||||
Common::strcat_s(in_name, ".csv");
|
||||
|
||||
infile = File::openForReading(in_name);
|
||||
}
|
||||
|
||||
if (outfile == nullptr) {
|
||||
// OPEN A TEMPORARY OUTPUT FILE TO WRITE THE MODIFICATIONS TO
|
||||
strcpy(out_name, data_directory);
|
||||
strcat(out_name, prefix);
|
||||
strcat(out_name, "-");
|
||||
strcat(out_name, text_of_word(1));
|
||||
strcat(out_name, "-");
|
||||
strcat(out_name, user_id);
|
||||
strcat(out_name, ".csv");
|
||||
Common::strcpy_s(out_name, data_directory);
|
||||
Common::strcat_s(out_name, prefix);
|
||||
Common::strcat_s(out_name, "-");
|
||||
Common::strcat_s(out_name, text_of_word(1));
|
||||
Common::strcat_s(out_name, "-");
|
||||
Common::strcat_s(out_name, user_id);
|
||||
Common::strcat_s(out_name, ".csv");
|
||||
|
||||
outfile = File::openForWriting(out_name);
|
||||
}
|
||||
@ -874,10 +874,10 @@ int execute(const char *funcname) {
|
||||
|
||||
if (word[1][0] == '!') {
|
||||
criterion_negate = TRUE;
|
||||
strcpy(argument_buffer, &word[1][1]);
|
||||
Common::strcpy_s(argument_buffer, &word[1][1]);
|
||||
} else {
|
||||
criterion_negate = FALSE;
|
||||
strcpy(argument_buffer, word[1]);
|
||||
Common::strcpy_s(argument_buffer, word[1]);
|
||||
}
|
||||
|
||||
// DETERMINE THE CRITERION FOR SELETION
|
||||
@ -1629,7 +1629,7 @@ int execute(const char *funcname) {
|
||||
string_buffer[0] = 0;
|
||||
|
||||
for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) {
|
||||
strcat(string_buffer, arg_text_of_word(counter));
|
||||
Common::strcat_s(string_buffer, arg_text_of_word(counter));
|
||||
}
|
||||
|
||||
if (function_resolve(string_buffer) == nullptr && !strcmp(word[0], "execute")) {
|
||||
@ -1734,7 +1734,7 @@ int execute(const char *funcname) {
|
||||
} else if (text_buffer[index - 1] != '^') {
|
||||
// ADD AN IMPLICIT SPACE IF THE PREVIOUS LINE
|
||||
// DIDN'T END WITH A CARRIAGE RETURN
|
||||
strcat(text_buffer, " ");
|
||||
Common::strcat_s(text_buffer, 1024, " ");
|
||||
}
|
||||
|
||||
// OUTPUT THE LINE READ AS PLAIN TEXT
|
||||
@ -1838,8 +1838,8 @@ int execute(const char *funcname) {
|
||||
char *match = nullptr;
|
||||
struct string_type *resolved_splitstring = nullptr;
|
||||
|
||||
strcpy(split_buffer, text_of_word(2));
|
||||
strcpy(delimiter, text_of_word(3));
|
||||
Common::strcpy_s(split_buffer, text_of_word(2));
|
||||
Common::strcpy_s(delimiter, text_of_word(3));
|
||||
|
||||
char *source = split_buffer;
|
||||
|
||||
@ -1860,32 +1860,32 @@ int execute(const char *funcname) {
|
||||
|
||||
while ((match = strstr(source, delimiter))) {
|
||||
*match = 0;
|
||||
strcpy(container_buffer, var_text_of_word(4));
|
||||
strcat(container_buffer, "[");
|
||||
Common::strcpy_s(container_buffer, var_text_of_word(4));
|
||||
Common::strcat_s(container_buffer, "[");
|
||||
sprintf(integer_buffer, "%d", *split_container);
|
||||
strcat(container_buffer, integer_buffer);
|
||||
strcat(container_buffer, "]");
|
||||
Common::strcat_s(container_buffer, integer_buffer);
|
||||
Common::strcat_s(container_buffer, "]");
|
||||
|
||||
if ((resolved_splitstring = string_resolve(container_buffer)) == nullptr) {
|
||||
unkstrrun(var_text_of_word(4));
|
||||
return (exit_function(TRUE));
|
||||
} else {
|
||||
strcpy(resolved_splitstring->value, source);
|
||||
Common::strcpy_s(resolved_splitstring->value, source);
|
||||
source = match + strlen(delimiter);
|
||||
(*split_container)++;
|
||||
}
|
||||
}
|
||||
strcpy(container_buffer, var_text_of_word(4));
|
||||
strcat(container_buffer, "[");
|
||||
Common::strcpy_s(container_buffer, var_text_of_word(4));
|
||||
Common::strcat_s(container_buffer, "[");
|
||||
sprintf(integer_buffer, "%d", *split_container);
|
||||
strcat(container_buffer, integer_buffer);
|
||||
strcat(container_buffer, "]");
|
||||
Common::strcat_s(container_buffer, integer_buffer);
|
||||
Common::strcat_s(container_buffer, "]");
|
||||
|
||||
if ((resolved_splitstring = string_resolve(container_buffer)) == nullptr) {
|
||||
unkstrrun(word[1]);
|
||||
return (exit_function(TRUE));
|
||||
} else {
|
||||
strcpy(resolved_splitstring->value, source);
|
||||
Common::strcpy_s(resolved_splitstring->value, source);
|
||||
(*split_container)++;
|
||||
}
|
||||
}
|
||||
@ -1908,7 +1908,7 @@ int execute(const char *funcname) {
|
||||
|
||||
/* RESOLVE ALL THE TEXT AND STORE IT IN A TEMPORARY BUFFER*/
|
||||
for (counter = 2; word[counter] != nullptr && counter < MAX_WORDS; counter++) {
|
||||
strcat(setstring_buffer, text_of_word(counter));
|
||||
Common::strcat_s(setstring_buffer, text_of_word(counter));
|
||||
}
|
||||
|
||||
/* setstring_buffer IS NOW FILLED, COPY THE UP TO 256 BYTES OF
|
||||
@ -1941,7 +1941,7 @@ int execute(const char *funcname) {
|
||||
index = value_of(word[3], TRUE);
|
||||
|
||||
for (counter = 0; counter < index; counter++) {
|
||||
strcat(setstring_buffer, text_of_word(2));
|
||||
Common::strcat_s(setstring_buffer, text_of_word(2));
|
||||
}
|
||||
|
||||
/* setstring_buffer IS NOW FILLED, COPY THE UP TO 256 BYTES OF
|
||||
@ -2184,11 +2184,11 @@ int execute(const char *funcname) {
|
||||
noproprun();
|
||||
return (exit_function(TRUE));
|
||||
} else {
|
||||
strcpy(temp_buffer, data_directory);
|
||||
strcat(temp_buffer, prefix);
|
||||
strcat(temp_buffer, "-");
|
||||
strcat(temp_buffer, text_of_word(1));
|
||||
strcat(temp_buffer, ".csv");
|
||||
Common::strcpy_s(temp_buffer, 1024, data_directory);
|
||||
Common::strcat_s(temp_buffer, 1024, prefix);
|
||||
Common::strcat_s(temp_buffer, 1024, "-");
|
||||
Common::strcat_s(temp_buffer, 1024, text_of_word(1));
|
||||
Common::strcat_s(temp_buffer, 1024, ".csv");
|
||||
|
||||
outfile = File::openForWriting(temp_buffer);
|
||||
|
||||
@ -2310,7 +2310,7 @@ int execute(const char *funcname) {
|
||||
string_buffer[0] = 0;
|
||||
|
||||
for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) {
|
||||
strcat(string_buffer, arg_text_of_word(counter));
|
||||
Common::strcat_s(string_buffer, arg_text_of_word(counter));
|
||||
}
|
||||
|
||||
if (execute(string_buffer)) {
|
||||
@ -2397,8 +2397,8 @@ char *object_names(int object_index, char *names_buffer) {
|
||||
names_buffer[0] = 0;
|
||||
|
||||
while (current_name != nullptr) {
|
||||
strcat(names_buffer, " ");
|
||||
strcat(names_buffer, current_name->name);
|
||||
Common::strcat_s(names_buffer, 1024, " ");
|
||||
Common::strcat_s(names_buffer, 1024, current_name->name);
|
||||
current_name = current_name->next_name;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ void glk_main() {
|
||||
status_line();
|
||||
|
||||
if (current_command != nullptr) {
|
||||
strcpy(last_command, current_command);
|
||||
Common::strcpy_s(last_command, current_command);
|
||||
}
|
||||
|
||||
if (inputwin == promptwin) {
|
||||
@ -404,7 +404,7 @@ void glk_main() {
|
||||
if (text_buffer[0] == 0) {
|
||||
/* NO COMMAND WAS SPECIFIED, FILL THE COMMAND IN AS 'blankjacl'
|
||||
* FOR THE GAME TO PROCESS AS DESIRED */
|
||||
strcpy(text_buffer, "blankjacl");
|
||||
Common::strcpy_s(text_buffer, 1024, "blankjacl");
|
||||
current_command = blank_command;
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ void glk_main() {
|
||||
} else {
|
||||
/* NO COMMAND WAS SPECIFIED, FILL THE COMMAND IN AS 'blankjacl'
|
||||
* FOR THE GAME TO PROCESS AS DESIRED */
|
||||
strcpy(text_buffer, "blankjacl");
|
||||
Common::strcpy_s(text_buffer, 1024, "blankjacl");
|
||||
command_encapsulate();
|
||||
preparse();
|
||||
}
|
||||
@ -530,8 +530,8 @@ void word_check() {
|
||||
TIME->value = FALSE;
|
||||
}
|
||||
} else {
|
||||
strcpy(oops_buffer, word[wp]);
|
||||
strcpy(text_buffer, last_command);
|
||||
Common::strcpy_s(oops_buffer, word[wp]);
|
||||
Common::strcpy_s(text_buffer, 1024, last_command);
|
||||
command_encapsulate();
|
||||
//printf("--- trying to replace %s with %s\n", word[oops_word], oops_buffer);
|
||||
jacl_truncate();
|
||||
@ -543,10 +543,10 @@ void word_check() {
|
||||
|
||||
while (word[index] != nullptr) {
|
||||
if (oopsed_current[0] != 0) {
|
||||
strcat(oopsed_current, " ");
|
||||
Common::strcat_s(oopsed_current, " ");
|
||||
}
|
||||
|
||||
strcat(oopsed_current, word[index]);
|
||||
Common::strcat_s(oopsed_current, word[index]);
|
||||
|
||||
index++;
|
||||
}
|
||||
@ -570,7 +570,7 @@ void word_check() {
|
||||
write_text(cstring_resolve("NOT_CLEVER")->value);
|
||||
TIME->value = FALSE;
|
||||
} else {
|
||||
strcpy(text_buffer, last_command);
|
||||
Common::strcpy_s(text_buffer, 1024, last_command);
|
||||
current_command = last_command;
|
||||
command_encapsulate();
|
||||
jacl_truncate();
|
||||
@ -1186,7 +1186,7 @@ void walking_thru() {
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(script_line, text_buffer);
|
||||
Common::strcpy_s(script_line, text_buffer);
|
||||
|
||||
while (result && INTERRUPTED->value == FALSE) {
|
||||
/* THERE COULD BE A LOT OF PROCESSING GOING ON HERE BEFORE GETTING
|
||||
@ -1222,7 +1222,7 @@ void walking_thru() {
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(script_line, text_buffer);
|
||||
Common::strcpy_s(script_line, text_buffer);
|
||||
}
|
||||
|
||||
/* CLOSE THE STREAM */
|
||||
|
@ -96,7 +96,7 @@ int jpp() {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
strcpy(processed_file, game_file);
|
||||
Common::strcpy_s(processed_file, 256, game_file);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
@ -183,10 +183,10 @@ int process_file(const char *sourceFile1, char *sourceFile2) {
|
||||
includeFile = strchr(text_buffer, '"');
|
||||
|
||||
if (includeFile != nullptr) {
|
||||
strcpy(temp_buffer1, game_path);
|
||||
strcat(temp_buffer1, includeFile + 1);
|
||||
strcpy(temp_buffer2, include_directory);
|
||||
strcat(temp_buffer2, includeFile + 1);
|
||||
Common::strcpy_s(temp_buffer1, game_path);
|
||||
Common::strcat_s(temp_buffer1, includeFile + 1);
|
||||
Common::strcpy_s(temp_buffer2, include_directory);
|
||||
Common::strcat_s(temp_buffer2, includeFile + 1);
|
||||
if (process_file(temp_buffer1, temp_buffer2) == FALSE) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ void read_gamefile() {
|
||||
outofmem();
|
||||
else {
|
||||
current_function = function_table;
|
||||
strcpy(current_function->name, "JACL*Internal");
|
||||
Common::strcpy_s(current_function->name, "JACL*Internal");
|
||||
current_function->position = 0;
|
||||
current_function->self = 0;
|
||||
current_function->call_count = 0;
|
||||
@ -329,10 +329,10 @@ void read_gamefile() {
|
||||
object[objects]->label[40] = 0;
|
||||
object[objects]->first_plural = nullptr;
|
||||
|
||||
strcpy(object[objects]->described, object[objects]->label);
|
||||
strcpy(object[objects]->inventory, object[objects]->label);
|
||||
strcpy(object[objects]->article, "the");
|
||||
strcpy(object[objects]->definite, "the");
|
||||
Common::strcpy_s(object[objects]->described, object[objects]->label);
|
||||
Common::strcpy_s(object[objects]->inventory, object[objects]->label);
|
||||
Common::strcpy_s(object[objects]->article, "the");
|
||||
Common::strcpy_s(object[objects]->definite, "the");
|
||||
object[objects]->attributes = FALSE;
|
||||
object[objects]->user_attributes = FALSE;
|
||||
|
||||
@ -694,8 +694,9 @@ void read_gamefile() {
|
||||
errors++;
|
||||
} else {
|
||||
strncpy(function_name, word[wp], 59);
|
||||
strcat(function_name, "_");
|
||||
strcat(function_name, object[object_count]->label);
|
||||
function_name[60] = '\0';
|
||||
Common::strcat_s(function_name, "_");
|
||||
Common::strcat_s(function_name, object[object_count]->label);
|
||||
self_parent = object_count;
|
||||
}
|
||||
if (function_table == nullptr) {
|
||||
@ -708,7 +709,7 @@ void read_gamefile() {
|
||||
functions++;
|
||||
|
||||
current_function = function_table;
|
||||
strcpy(current_function->name, function_name);
|
||||
Common::strcpy_s(current_function->name, function_name);
|
||||
|
||||
current_function->position = g_vm->glk_stream_get_position(game_stream);
|
||||
current_function->call_count = 0;
|
||||
@ -727,7 +728,7 @@ void read_gamefile() {
|
||||
functions++;
|
||||
|
||||
current_function = current_function->next_function;
|
||||
strcpy(current_function->name, function_name);
|
||||
Common::strcpy_s(current_function->name, function_name);
|
||||
|
||||
current_function->position = g_vm->glk_stream_get_position(game_stream);
|
||||
current_function->call_count = 0;
|
||||
|
@ -386,32 +386,32 @@ void call_functions(const char *base_name) {
|
||||
TIME->value = TRUE;
|
||||
|
||||
strncpy(base_function, base_name + 1, 80);
|
||||
strcat(base_function, "_");
|
||||
Common::strcat_s(base_function, "_");
|
||||
|
||||
strncpy(override_, base_function, 80);
|
||||
|
||||
strcpy(before_function, "+before_");
|
||||
strcat(before_function, base_name + 1);
|
||||
Common::strcpy_s(before_function, "+before_");
|
||||
Common::strcat_s(before_function, base_name + 1);
|
||||
|
||||
strcpy(after_function, "+after_");
|
||||
strcat(after_function, base_name + 1);
|
||||
Common::strcpy_s(after_function, "+after_");
|
||||
Common::strcat_s(after_function, base_name + 1);
|
||||
|
||||
strcpy(local_after_function, "after_");
|
||||
strcat(local_after_function, base_name + 1);
|
||||
Common::strcpy_s(local_after_function, "after_");
|
||||
Common::strcat_s(local_after_function, base_name + 1);
|
||||
if (noun[1] != FALSE) {
|
||||
strcat(local_after_function, "_");
|
||||
strcat(local_after_function, object[noun[1]]->label);
|
||||
Common::strcat_s(local_after_function, "_");
|
||||
Common::strcat_s(local_after_function, object[noun[1]]->label);
|
||||
}
|
||||
if (noun[0] != FALSE) {
|
||||
strcat(local_after_function, "_");
|
||||
strcat(local_after_function, object[noun[0]]->label);
|
||||
Common::strcat_s(local_after_function, "_");
|
||||
Common::strcat_s(local_after_function, object[noun[0]]->label);
|
||||
}
|
||||
|
||||
/* THIS IS CALLED IF AN 'override' COMMAND IS EXECUTED
|
||||
* IN A LIBRARY FUNCTION BUT THE OBJECT-OR-LOCATION-SPECIFIC
|
||||
* OVERRIDE DOES NOT EXIST. IT IS SET TO '+default_func' */
|
||||
strcpy(default_function, "+default_");
|
||||
strcat(default_function, base_name + 1);
|
||||
Common::strcpy_s(default_function, "+default_");
|
||||
Common::strcat_s(default_function, base_name + 1);
|
||||
|
||||
/* EXECUTE THE GLOBAL *DEFAULT* BEFORE FUNCTION
|
||||
* AND RETURN IF IT RETURNS TRUE */
|
||||
@ -424,7 +424,7 @@ void call_functions(const char *base_name) {
|
||||
return;
|
||||
|
||||
if (noun[0] == FALSE) { /* USER'S COMMAND HAS NO NOUNS */
|
||||
strcat(base_function, object[HERE]->label);
|
||||
Common::strcat_s(base_function, object[HERE]->label);
|
||||
/* EXECUTE THE FUNCTION 'func_here' */
|
||||
if (execute(base_function) == FALSE) {
|
||||
/* THIS LOCATION-SPECIFIC FUNCTION DOES NOT
|
||||
@ -438,19 +438,19 @@ void call_functions(const char *base_name) {
|
||||
|
||||
/* PREPARE THE OVERRIDE FUNCTION NAME IN CASE IT
|
||||
* IS NEEDED */
|
||||
strcat(override_, "override_");
|
||||
strcat(override_, object[HERE]->label);
|
||||
Common::strcat_s(override_, 81, "override_");
|
||||
Common::strcat_s(override_, 81, object[HERE]->label);
|
||||
|
||||
/* CREATE THE FUNCTION NAME '+func' */
|
||||
strcpy(base_function, "+");
|
||||
strcat(base_function, base_name + 1);
|
||||
Common::strcpy_s(base_function, "+");
|
||||
Common::strcat_s(base_function, base_name + 1);
|
||||
|
||||
/* CALL THE LIBRARY'S DEFAULT BEHAVIOR */
|
||||
if (execute(base_function) == FALSE)
|
||||
unkfunrun(base_function);
|
||||
}
|
||||
} else if (noun[1] == FALSE) { /* USER'S COMMAND HAS ONE NOUN */
|
||||
strcat(base_function, object[noun[0]]->label);
|
||||
Common::strcat_s(base_function, object[noun[0]]->label);
|
||||
/* EXECUTE THE FUNCTION 'func_noun1' */
|
||||
if (execute(base_function) == FALSE) {
|
||||
/* THIS OBJECT-SPECIFIC FUNCTION DOES NOT
|
||||
@ -464,21 +464,21 @@ void call_functions(const char *base_name) {
|
||||
|
||||
/* PREPARE THE OVERRIDE FUNCTION NAME IN CASE IT
|
||||
* IS NEEDED */
|
||||
strcat(override_, "override_");
|
||||
strcat(override_, object[noun[0]]->label);
|
||||
Common::strcat_s(override_, 81, "override_");
|
||||
Common::strcat_s(override_, 81, object[noun[0]]->label);
|
||||
|
||||
/* CREATE THE FUNCTION NAME '+func' */
|
||||
strcpy(base_function, "+");
|
||||
strcat(base_function, base_name + 1);
|
||||
Common::strcpy_s(base_function, "+");
|
||||
Common::strcat_s(base_function, base_name + 1);
|
||||
|
||||
/* CALL THE LIBRARY'S DEFAULT BEHAVIOR */
|
||||
if (execute(base_function) == FALSE)
|
||||
unkfunrun(base_function);
|
||||
}
|
||||
} else { /* USER'S COMMAND HAS TWO NOUNS */
|
||||
strcat(base_function, object[noun[1]]->label);
|
||||
strcat(base_function, "_");
|
||||
strcat(base_function, object[noun[0]]->label);
|
||||
Common::strcat_s(base_function, object[noun[1]]->label);
|
||||
Common::strcat_s(base_function, "_");
|
||||
Common::strcat_s(base_function, object[noun[0]]->label);
|
||||
/* EXECUTE THE FUNCTION 'func_noun2_noun1'
|
||||
* IE give_to_fred THAT IS ASSOCIATED WITH
|
||||
* THE OBJECT flint_stone */
|
||||
@ -494,13 +494,13 @@ void call_functions(const char *base_name) {
|
||||
|
||||
/* PREPARE THE OVERRIDE FUNCTION NAME IN CASE IT
|
||||
* IS NEEDED */
|
||||
strcat(override_, object[noun[1]]->label);
|
||||
strcat(override_, "_override_");
|
||||
strcat(override_, object[noun[0]]->label);
|
||||
Common::strcat_s(override_, 81, object[noun[1]]->label);
|
||||
Common::strcat_s(override_, 81, "_override_");
|
||||
Common::strcat_s(override_, 81, object[noun[0]]->label);
|
||||
|
||||
/* CREATE THE FUNCTION NAME '+func' */
|
||||
strcpy(base_function, "+");
|
||||
strcat(base_function, base_name + 1);
|
||||
Common::strcpy_s(base_function, "+");
|
||||
Common::strcat_s(base_function, base_name + 1);
|
||||
|
||||
/* CALL THE LIBRARY'S DEFAULT BEHAVIOR */
|
||||
if (execute(base_function) == FALSE)
|
||||
@ -1128,9 +1128,9 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number
|
||||
}
|
||||
|
||||
object_expected = TRUE;
|
||||
strcpy(object_name, word[wp]);
|
||||
strcat(object_name, " ");
|
||||
strcat(object_name, cstring_resolve("OF_WORD")->value);
|
||||
Common::strcpy_s(object_name, word[wp]);
|
||||
Common::strcat_s(object_name, " ");
|
||||
Common::strcat_s(object_name, cstring_resolve("OF_WORD")->value);
|
||||
|
||||
/* MOVE THE WORD POINTER TO AFTER THE 'OF' */
|
||||
wp = wp + 2;
|
||||
@ -1147,9 +1147,9 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number
|
||||
// ADD THE WORDS USED TO error_buffer FOR POSSIBLE USE
|
||||
// IN A DISABMIGUATE EMESSAGE
|
||||
if (first_word == FALSE) {
|
||||
strcat(error_buffer, " ");
|
||||
Common::strcat_s(error_buffer, 1024, " ");
|
||||
}
|
||||
strcat(error_buffer, word[wp]);
|
||||
Common::strcat_s(error_buffer, 1024, word[wp]);
|
||||
first_word = FALSE;
|
||||
|
||||
/* LOOP THROUGH WORDS IN THE PLAYER'S INPUT */
|
||||
@ -1203,9 +1203,9 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number
|
||||
* IS TRYING TO REFER TO FOR USE IN AN ERROR MESSAGE IF
|
||||
* LATER REQUIRED */
|
||||
if (object_name[0] != 0)
|
||||
strcat(object_name, " ");
|
||||
Common::strcat_s(object_name, " ");
|
||||
|
||||
strcat(object_name, word[wp]);
|
||||
Common::strcat_s(object_name, word[wp]);
|
||||
|
||||
if (!strcmp("everything", word[wp])) {
|
||||
/* ALL THIS NEEDS TO SIGNIFY IS THAT IT IS OKAY TO RETURN MULTIPLE
|
||||
|
@ -65,7 +65,9 @@ extern void create_cinteger(const char *name, int value);
|
||||
extern void scripting();
|
||||
extern void undoing();
|
||||
extern void walking_thru();
|
||||
#ifndef GLK
|
||||
extern void create_paths(char *full_path);
|
||||
#endif
|
||||
extern int get_key();
|
||||
extern char get_character(const char *message);
|
||||
extern int get_yes_or_no();
|
||||
|
@ -747,10 +747,10 @@ const char *expand_function(const char *name) {
|
||||
* ELEMENT, SO TAKE NOTE OF THAT */
|
||||
sprintf(function_name, "%ld", value_of(&expression[delimiter], TRUE));
|
||||
} else {
|
||||
strcpy(function_name, &expression[delimiter]);
|
||||
Common::strcpy_s(function_name, 81, &expression[delimiter]);
|
||||
}
|
||||
strcat(function_name, "_");
|
||||
strcat(function_name, object[index]->label);
|
||||
Common::strcat_s(function_name, 81, "_");
|
||||
Common::strcat_s(function_name, 81, object[index]->label);
|
||||
|
||||
return ((const char *) function_name);
|
||||
}
|
||||
@ -872,9 +872,10 @@ char *macro_resolve(const char *testString) {
|
||||
return (nullptr);
|
||||
} else {
|
||||
if (object[index]->attributes & PLURAL) {
|
||||
strcpy(temp_buffer, "");
|
||||
temp_buffer[0] = '\0';
|
||||
} else {
|
||||
strcpy(temp_buffer, "s");
|
||||
temp_buffer[0] = 's';
|
||||
temp_buffer[1] = '\0';
|
||||
}
|
||||
return (temp_buffer);
|
||||
}
|
||||
@ -970,11 +971,11 @@ char *macro_resolve(const char *testString) {
|
||||
return (sentence_output(index, TRUE));
|
||||
}
|
||||
} else {
|
||||
strcpy(macro_function, "+macro_");
|
||||
strcat(macro_function, &expression[delimiter]);
|
||||
strcat(macro_function, "<");
|
||||
Common::strcpy_s(macro_function, "+macro_");
|
||||
Common::strcat_s(macro_function, &expression[delimiter]);
|
||||
Common::strcat_s(macro_function, "<");
|
||||
sprintf(temp_buffer, "%d", index);
|
||||
strcat(macro_function, temp_buffer);
|
||||
Common::strcat_s(macro_function, temp_buffer);
|
||||
|
||||
// BUILD THE FUNCTION NAME AND PASS THE OBJECT AS
|
||||
// THE ONLY ARGUMENT
|
||||
|
@ -53,8 +53,8 @@ void eachturn() {
|
||||
* OCCURING DUE TO THE PASSING OF TIME */
|
||||
TOTAL_MOVES->value++;
|
||||
execute("+eachturn");
|
||||
strcpy(function_name, "eachturn_");
|
||||
strcat(function_name, object[HERE]->label);
|
||||
Common::strcpy_s(function_name, 81, "eachturn_");
|
||||
Common::strcat_s(function_name, 81, object[HERE]->label);
|
||||
execute(function_name);
|
||||
execute("+system_eachturn");
|
||||
|
||||
@ -106,6 +106,7 @@ int random_number() {
|
||||
return g_vm->getRandomNumber(0x7fffffff);
|
||||
}
|
||||
|
||||
#ifndef GLK
|
||||
void create_paths(char *full_path) {
|
||||
int index;
|
||||
char *last_slash;
|
||||
@ -181,6 +182,7 @@ void create_paths(char *full_path) {
|
||||
strcat(data_directory, DATA_DIR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int jacl_whitespace(char character) {
|
||||
/* CHECK IF A CHARACTER IS CONSIDERED WHITE SPACE IN THE JACL LANGUAGE */
|
||||
|
@ -1227,7 +1227,7 @@ void calldriver() {
|
||||
*list9startptr = *a6;
|
||||
} else if (d0 == 0x0b) {
|
||||
char NewName[MAX_PATH];
|
||||
strcpy(NewName, LastGame);
|
||||
Common::strcpy_s(NewName, LastGame);
|
||||
if (*a6 == 0) {
|
||||
printstring("\rSearching for next sub-game file.\r");
|
||||
if (!os_get_game_file(NewName, MAX_PATH)) {
|
||||
@ -1553,7 +1553,7 @@ L9BOOL GetWordV3(char *buff, int Word) {
|
||||
Word++; /* force unpack again */
|
||||
}
|
||||
}
|
||||
strcpy(buff, threechars);
|
||||
Common::strcpy_s(buff, IBUFFSIZE, threechars);
|
||||
for (i = 0; i < (int)strlen(buff); i++) buff[i] &= 0x7f;
|
||||
return TRUE;
|
||||
}
|
||||
@ -2991,7 +2991,7 @@ L9BOOL LoadGame2(const char *filename, char *picname) {
|
||||
randomseed = constseed;
|
||||
else
|
||||
randomseed = (L9UINT16)g_system->getMillis();
|
||||
strcpy(LastGame, filename);
|
||||
Common::strcpy_s(LastGame, filename);
|
||||
return Running = TRUE;
|
||||
}
|
||||
|
||||
|
@ -3517,8 +3517,9 @@ static int gln_command_escape(const char *string) {
|
||||
return FALSE;
|
||||
|
||||
/* Take a copy of the string, without any leading space or introducer. */
|
||||
string_copy = (char *)gln_malloc(strlen(string + posn) + 1 - strlen("glk"));
|
||||
strcpy(string_copy, string + posn + strlen("glk"));
|
||||
size_t ln = strlen(string + posn) + 1 - 3/*strlen("glk")*/;
|
||||
string_copy = (char *)gln_malloc(ln);
|
||||
Common::strcpy_s(string_copy, ln, string + posn + 3/*strlen("glk")*/);
|
||||
|
||||
/*
|
||||
* Find the subcommand; the first word in the string copy. Find its end,
|
||||
@ -3625,8 +3626,9 @@ static int gln_command_intercept(char *string) {
|
||||
|
||||
/* Take a copy of the string, excluding any leading whitespace. */
|
||||
posn = strspn(string, "\t ");
|
||||
string_copy = (char *)gln_malloc(strlen(string + posn) + 1);
|
||||
strcpy(string_copy, string + posn);
|
||||
size_t ln = strlen(string + posn) + 1;
|
||||
string_copy = (char *)gln_malloc(ln);
|
||||
Common::strcpy_s(string_copy, ln, string + posn);
|
||||
|
||||
/*
|
||||
* Find the space or NUL after the first word, and check that anything
|
||||
@ -4500,8 +4502,9 @@ static void gln_establish_picture_filename(const char *name, char **graphics) {
|
||||
assert(name && graphics);
|
||||
|
||||
/* Take a destroyable copy of the input filename. */
|
||||
base = (char *)gln_malloc(strlen(name) + 1);
|
||||
strcpy(base, name);
|
||||
size_t ln = strlen(name) + 1;
|
||||
base = (char *)gln_malloc(ln);
|
||||
Common::strcpy_s(base, ln, name);
|
||||
|
||||
/* If base has an extension .LEV, .SNA, or similar, remove it. */
|
||||
if (strrchr(base, '.')) {
|
||||
@ -4509,44 +4512,45 @@ static void gln_establish_picture_filename(const char *name, char **graphics) {
|
||||
}
|
||||
|
||||
/* Allocate space for the return graphics file. */
|
||||
graphics_file = (char *)gln_malloc(strlen(base) + strlen(".___") + 1);
|
||||
ln = strlen(base) + 4/*strlen(".___")*/ + 1;
|
||||
graphics_file = (char *)gln_malloc(ln);
|
||||
|
||||
/* Form a candidate graphics file, using a .PIC extension. */
|
||||
if (!f.isOpen()) {
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".PIC");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".PIC");
|
||||
f.open(graphics_file);
|
||||
}
|
||||
|
||||
if (!f.isOpen()) {
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".pic");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".pic");
|
||||
f.open(graphics_file);
|
||||
}
|
||||
|
||||
/* Form a candidate graphics file, using a .CGA extension. */
|
||||
if (!f.isOpen()) {
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".CGA");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".CGA");
|
||||
f.open(graphics_file);
|
||||
}
|
||||
|
||||
if (!f.isOpen()) {
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".cga");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".cga");
|
||||
f.open(graphics_file);
|
||||
}
|
||||
|
||||
/* Form a candidate graphics file, using a .HRC extension. */
|
||||
if (!f.isOpen()) {
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".HRC");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".HRC");
|
||||
f.open(graphics_file);
|
||||
}
|
||||
|
||||
if (!f.isOpen()) {
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".hrc");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".hrc");
|
||||
f.open(graphics_file);
|
||||
}
|
||||
|
||||
@ -4566,16 +4570,17 @@ static void gln_establish_picture_filename(const char *name, char **graphics) {
|
||||
}
|
||||
|
||||
/* Again, allocate space for the return graphics file. */
|
||||
graphics_file = (char *)gln_malloc(strlen(base) + strlen("PICTURE.DAT") + 1);
|
||||
ln = strlen(base) + strlen("PICTURE.DAT") + 1;
|
||||
graphics_file = (char *)gln_malloc(ln);
|
||||
|
||||
/* As above, form a candidate graphics file. */
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, "PICTURE.DAT");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, "PICTURE.DAT");
|
||||
|
||||
if (!f.open(graphics_file)) {
|
||||
/* Retry, using picture.dat extension instead. */
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, "picture.dat");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, "picture.dat");
|
||||
if (!f.open(graphics_file)) {
|
||||
/*
|
||||
* No access to this graphics file. In this case, free memory
|
||||
|
@ -3329,8 +3329,9 @@ int Magnetic::gms_command_escape(const char *string_, int *undo_command) {
|
||||
return false;
|
||||
|
||||
/* Take a copy of the string_, without any leading space or introducer. */
|
||||
size_t ln = strlen(string_ + posn) + 1 - 3/*strlen("glk")*/;
|
||||
string_copy = (char *)gms_malloc(strlen(string_ + posn) + 1 - strlen("glk"));
|
||||
strcpy(string_copy, string_ + posn + strlen("glk"));
|
||||
Common::strcpy_s(string_copy, ln, string_ + posn + 3/*strlen("glk")*/);
|
||||
|
||||
/*
|
||||
* Find the subcommand; the first word in the string copy. Find its end,
|
||||
@ -3725,8 +3726,9 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra
|
||||
assert(name && text && graphics && hints_);
|
||||
|
||||
/* Take a destroyable copy of the input filename. */
|
||||
base = (char *)gms_malloc(strlen(name) + 1);
|
||||
strcpy(base, name);
|
||||
size_t ln = strlen(name) + 1;
|
||||
base = (char *)gms_malloc(ln);
|
||||
Common::strcpy_s(base, ln, name);
|
||||
|
||||
/* If base has an extension .MAG, .GFX, or .HNT, remove it. */
|
||||
if (strlen(base) > strlen(".XXX")) {
|
||||
@ -3737,16 +3739,17 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra
|
||||
}
|
||||
|
||||
/* Allocate space for the return text file. */
|
||||
text_file = (char *)gms_malloc(strlen(base) + strlen(".MAG") + 1);
|
||||
ln = strlen(base) + 4/*strlen(".MAG")*/ + 1;
|
||||
text_file = (char *)gms_malloc(ln);
|
||||
|
||||
/* Form a candidate text file, by adding a .MAG extension. */
|
||||
strcpy(text_file, base);
|
||||
strcat(text_file, ".MAG");
|
||||
Common::strcpy_s(text_file, ln, base);
|
||||
Common::strcat_s(text_file, ln, ".MAG");
|
||||
|
||||
if (!stream.open(text_file)) {
|
||||
/* Retry, using a .mag extension instead. */
|
||||
strcpy(text_file, base);
|
||||
strcat(text_file, ".mag");
|
||||
Common::strcpy_s(text_file, ln, base);
|
||||
Common::strcat_s(text_file, ln, ".mag");
|
||||
|
||||
if (!stream.open(text_file)) {
|
||||
/*
|
||||
@ -3765,16 +3768,17 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra
|
||||
stream.close();
|
||||
|
||||
/* Now allocate space for the return graphics file. */
|
||||
graphics_file = (char *)gms_malloc(strlen(base) + strlen(".GFX") + 1);
|
||||
ln = strlen(base) + 4/*strlen(".GFX")*/ + 1;
|
||||
graphics_file = (char *)gms_malloc(ln);
|
||||
|
||||
/* As above, form a candidate graphics file, using a .GFX extension. */
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".GFX");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".GFX");
|
||||
|
||||
if (!stream.open(graphics_file)) {
|
||||
/* Retry, using a .gfx extension instead. */
|
||||
strcpy(graphics_file, base);
|
||||
strcat(graphics_file, ".gfx");
|
||||
Common::strcpy_s(graphics_file, ln, base);
|
||||
Common::strcat_s(graphics_file, ln, ".gfx");
|
||||
|
||||
if (!stream.open(graphics_file)) {
|
||||
/*
|
||||
@ -3788,16 +3792,17 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra
|
||||
stream.close();
|
||||
|
||||
/* Now allocate space for the return hints_ file. */
|
||||
hints_file = (char *)gms_malloc(strlen(base) + strlen(".HNT") + 1);
|
||||
ln = strlen(base) + 4/*strlen(".HNT")*/ + 1;
|
||||
hints_file = (char *)gms_malloc(ln);
|
||||
|
||||
/* As above, form a candidate graphics file, using a .HNT extension. */
|
||||
strcpy(hints_file, base);
|
||||
strcat(hints_file, ".HNT");
|
||||
Common::strcpy_s(hints_file, ln, base);
|
||||
Common::strcat_s(hints_file, ln, ".HNT");
|
||||
|
||||
if (!stream.open(hints_file)) {
|
||||
/* Retry, using a .hnt extension instead. */
|
||||
strcpy(hints_file, base);
|
||||
strcat(hints_file, ".hnt");
|
||||
Common::strcpy_s(hints_file, ln, base);
|
||||
Common::strcat_s(hints_file, ln, ".hnt");
|
||||
|
||||
if (!stream.open(hints_file)) {
|
||||
/*
|
||||
|
@ -476,7 +476,7 @@ int decrunchC64(uint8_t **sf, size_t *extent, C64Rec record) {
|
||||
|
||||
if (record._switches != nullptr) {
|
||||
char string[100];
|
||||
strcpy(string, record._switches);
|
||||
Common::strcpy_s(string, record._switches);
|
||||
switches[numSwitches] = strtok(string, " ");
|
||||
|
||||
while (switches[numSwitches] != nullptr)
|
||||
|
@ -375,7 +375,7 @@ const char *Scott::mapSynonym(int noun) {
|
||||
if (*tp == '*')
|
||||
tp++;
|
||||
else
|
||||
strcpy(lastword, tp);
|
||||
Common::strcpy_s(lastword, tp);
|
||||
if (n == noun)
|
||||
return lastword;
|
||||
n++;
|
||||
|
@ -587,7 +587,7 @@ int unp64(uint8_t *compressed, size_t length, uint8_t *destinationBuffer, size_t
|
||||
}
|
||||
|
||||
if (*forcedname) {
|
||||
strcpy(name, forcedname);
|
||||
Common::strcpy_s(name, forcedname);
|
||||
} else {
|
||||
if (strlen(name) > 248) /* dirty hack in case name is REALLY long */
|
||||
name[248] = 0;
|
||||
|
@ -187,7 +187,7 @@ bool os_locate(const char *fname, int flen, const char *arg0, char *buf, size_t
|
||||
}
|
||||
|
||||
osfildef *os_create_tempfile(const char *fname, char *buf) {
|
||||
strcpy(buf, "tmpfile");
|
||||
Common::strcpy_s(buf, OSFNMAX, "tmpfile");
|
||||
return new Common::MemoryReadWriteStream(DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ int osfdel_temp(const char *fname) {
|
||||
}
|
||||
|
||||
void os_get_tmp_path(char *buf) {
|
||||
strcpy(buf, "");
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
int os_gen_temp_filename(char *buf, size_t buflen) {
|
||||
@ -228,11 +228,11 @@ bool os_rmdir(const char *dir) {
|
||||
|
||||
void os_defext(char *fname, const char *ext) {
|
||||
if (!strchr(fname, '.'))
|
||||
strcat(fname, ext);
|
||||
Common::strcat_s(fname, OSFNMAX, ext);
|
||||
}
|
||||
|
||||
void os_addext(char *fname, const char *ext) {
|
||||
strcat(fname, ext);
|
||||
Common::strcat_s(fname, OSFNMAX, ext);
|
||||
}
|
||||
|
||||
void os_remext(char *fname) {
|
||||
@ -254,28 +254,28 @@ bool os_is_file_absolute(const char *fname) {
|
||||
}
|
||||
|
||||
void os_get_path_name(char *pathbuf, size_t pathbuflen, const char *fname) {
|
||||
strcpy(pathbuf, "");
|
||||
pathbuf[0] = '\0';
|
||||
}
|
||||
|
||||
void os_build_full_path(char *fullpathbuf, size_t fullpathbuflen,
|
||||
const char *path, const char *filename) {
|
||||
strcpy(fullpathbuf, filename);
|
||||
Common::strcpy_s(fullpathbuf, fullpathbuflen, filename);
|
||||
}
|
||||
|
||||
void os_combine_paths(char *fullpathbuf, size_t pathbuflen,
|
||||
const char *path, const char *filename) {
|
||||
strcpy(fullpathbuf, filename);
|
||||
Common::strcpy_s(fullpathbuf, pathbuflen, filename);
|
||||
}
|
||||
|
||||
bool os_get_abs_filename(char *result_buf, size_t result_buf_size,
|
||||
const char *filename) {
|
||||
strcpy(result_buf, filename);
|
||||
Common::strcpy_s(result_buf, result_buf_size, filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool os_get_rel_path(char *result_buf, size_t result_buf_size,
|
||||
const char *basepath, const char *filename) {
|
||||
strcpy(result_buf, filename);
|
||||
Common::strcpy_s(result_buf, result_buf_size, filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ int os_init(int *argc, char *argv[], const char *prompt,
|
||||
|
||||
g_vm->glk_set_window(mainwin);
|
||||
|
||||
strcpy(rbuf, "");
|
||||
rbuf[0] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -324,7 +324,7 @@ void os_status(int stat)
|
||||
winmethod_Above | winmethod_Fixed, 1,
|
||||
wintype_TextGrid, 0);
|
||||
}
|
||||
strcpy(lbuf, "");
|
||||
lbuf[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ int os_askfile(const char *prompt, char *fname_buf, int fname_buf_len,
|
||||
if (fileref == nullptr)
|
||||
return OS_AFE_CANCEL;
|
||||
|
||||
strcpy(fname_buf, g_vm->garglk_fileref_get_name(fileref));
|
||||
Common::strcpy_s(fname_buf, fname_buf_len, g_vm->garglk_fileref_get_name(fileref));
|
||||
|
||||
g_vm->glk_fileref_destroy(fileref);
|
||||
|
||||
@ -967,7 +967,7 @@ osfildef *os_exeseek(const char *argv0, const char *typ) {
|
||||
}
|
||||
|
||||
int os_get_str_rsc(int id, char *buf, size_t buflen) {
|
||||
strcpy(buf, "");
|
||||
buf[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -982,8 +982,9 @@ void os_dbg_vprintf(const char *fmt, va_list args) {
|
||||
int os_vasprintf(char **bufptr, const char *fmt, va_list ap) {
|
||||
Common::String s = Common::String::vformat(fmt, ap);
|
||||
|
||||
*bufptr = (char *)malloc(s.size() + 1);
|
||||
strcpy(*bufptr, s.c_str());
|
||||
size_t ln = s.size() + 1;
|
||||
*bufptr = (char *)malloc(ln);
|
||||
Common::strcpy_s(*bufptr, ln, s.c_str());
|
||||
return s.size();
|
||||
}
|
||||
|
||||
@ -1010,12 +1011,12 @@ void os_xlat_html4(unsigned int html4_char, char *result, size_t result_len) {
|
||||
case 132: /* double back quote */
|
||||
result[0] = '\"'; break;
|
||||
case 153: /* trade mark */
|
||||
strcpy(result, "(tm)"); return;
|
||||
Common::strcpy_s(result, result_len, "(tm)"); return;
|
||||
case 140: /* OE ligature */
|
||||
case 338: /* OE ligature */
|
||||
strcpy(result, "OE"); return;
|
||||
Common::strcpy_s(result, result_len, "OE"); return;
|
||||
case 339: /* oe ligature */
|
||||
strcpy(result, "oe"); return;
|
||||
Common::strcpy_s(result, result_len, "oe"); return;
|
||||
case 159: /* Yuml */
|
||||
result[0] = (char)255; return;
|
||||
case 376: /* Y with diaresis */
|
||||
@ -1029,7 +1030,7 @@ void os_xlat_html4(unsigned int html4_char, char *result, size_t result_len) {
|
||||
result[0] = '-'; break;
|
||||
case 151: /* em dash */
|
||||
case 8212: /* em dash */
|
||||
strcpy(result, "--"); return;
|
||||
Common::strcpy_s(result, result_len, "--"); return;
|
||||
case 145: /* left single quote */
|
||||
case 8216: /* left single quote */
|
||||
result[0] = '`'; break;
|
||||
|
@ -52,9 +52,9 @@ void bifyon(bifcxdef *ctx, int argc)
|
||||
|
||||
/* load the "yes" and "no" reply patterns */
|
||||
if (os_get_str_rsc(RESID_YORN_YES, yesbuf, sizeof(yesbuf)))
|
||||
strcpy(yesbuf, "[Yy].*");
|
||||
Common::strcpy_s(yesbuf, "[Yy].*");
|
||||
if (os_get_str_rsc(RESID_YORN_NO, nobuf, sizeof(nobuf)))
|
||||
strcpy(nobuf, "[Nn].*");
|
||||
Common::strcpy_s(nobuf, "[Nn].*");
|
||||
|
||||
/* if we're in HTML mode, switch to input font */
|
||||
if (tio_is_html_mode())
|
||||
@ -2047,27 +2047,27 @@ static int get_ext_key_name(char *namebuf, int c, int extc)
|
||||
case 10:
|
||||
case 13:
|
||||
/* return '\n' for LF and CR characters */
|
||||
strcpy(namebuf, "\\n");
|
||||
Common::strcpy_s(namebuf, 20, "\\n");
|
||||
return TRUE;
|
||||
|
||||
case 9:
|
||||
/* return '\t' for TAB characters */
|
||||
strcpy(namebuf, "\\t");
|
||||
Common::strcpy_s(namebuf, 20, "\\t");
|
||||
return TRUE;
|
||||
|
||||
case 8:
|
||||
/* return '[bksp]' for backspace characters */
|
||||
strcpy(namebuf, "[bksp]");
|
||||
Common::strcpy_s(namebuf, 20, "[bksp]");
|
||||
return TRUE;
|
||||
|
||||
case 27:
|
||||
/* return '[esc]' for the escape key */
|
||||
strcpy(namebuf, "[esc]");
|
||||
Common::strcpy_s(namebuf, 20, "[esc]");
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
/* return '[ctrl-X]' for other control characters */
|
||||
strcpy(namebuf, "[ctrl-X]");
|
||||
Common::strcpy_s(namebuf, 20, "[ctrl-X]");
|
||||
namebuf[6] = (char)(c + 'a' - 1);
|
||||
return TRUE;
|
||||
}
|
||||
@ -2086,7 +2086,7 @@ static int get_ext_key_name(char *namebuf, int c, int extc)
|
||||
&& extc <= (int)(sizeof(ext_key_names)/sizeof(ext_key_names[0])))
|
||||
{
|
||||
/* use the array name */
|
||||
strcpy(namebuf, ext_key_names[extc - 1]);
|
||||
Common::strcpy_s(namebuf, 20, ext_key_names[extc - 1]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2094,13 +2094,13 @@ static int get_ext_key_name(char *namebuf, int c, int extc)
|
||||
if (extc >= CMD_ALT && extc <= CMD_ALT + 25)
|
||||
{
|
||||
/* generate an ALT key name */
|
||||
strcpy(namebuf, "[alt-X]");
|
||||
Common::strcpy_s(namebuf, 20, "[alt-X]");
|
||||
namebuf[5] = (char)(extc - CMD_ALT + 'a');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* it's not a valid key - use '[?]' as the name */
|
||||
strcpy(namebuf, "[?]");
|
||||
Common::strcpy_s(namebuf, 20, "[?]");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2174,7 +2174,7 @@ void bifwrd(bifcxdef *ctx, int argc)
|
||||
*dst++ = DAT_SSTRING;
|
||||
len = strlen((const char *)src);
|
||||
oswp2(dst, len + 2);
|
||||
strcpy((char *)dst + 2, (const char *)src);
|
||||
Common::strcpy_s((char *)dst + 2, sizeof(buf) - (dst + 2 - buf), (const char *)src);
|
||||
dst += len + 2;
|
||||
}
|
||||
}
|
||||
@ -2507,7 +2507,7 @@ void biffopen(bifcxdef *ctx, int argc)
|
||||
ctx->bifcxrun->runcxgamepath, fname);
|
||||
|
||||
/* replace the original filename with the full path */
|
||||
strcpy(fname, newname);
|
||||
Common::strcpy_s(fname, newname);
|
||||
}
|
||||
|
||||
/* get the mode string */
|
||||
|
@ -74,7 +74,7 @@ void cmap_init_default(void)
|
||||
memset(G_cmap_id, 0, sizeof(G_cmap_id));
|
||||
|
||||
/* indicate that it's the default */
|
||||
strcpy(G_cmap_ldesc, "(native/no mapping)");
|
||||
Common::strcpy_s(G_cmap_ldesc, "(native/no mapping)");
|
||||
|
||||
/* note that we have no character set loaded */
|
||||
S_cmap_loaded = FALSE;
|
||||
@ -331,7 +331,7 @@ void cmap_set_game_charset(errcxdef *ec,
|
||||
* provide here. Save the game's character set ldesc for that
|
||||
* eventuality, since it describes exactly what the *game* wanted.
|
||||
*/
|
||||
strcpy(G_cmap_ldesc, internal_ldesc);
|
||||
Common::strcpy_s(G_cmap_ldesc, internal_ldesc);
|
||||
}
|
||||
|
||||
} // End of namespace TADS2
|
||||
|
@ -2444,8 +2444,8 @@ static void voc_askobj_indirect(voccxdef *ctx, vocoldef *dolist,
|
||||
*/
|
||||
int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
char *vverb, char *vprep, vocoldef *dolist, vocoldef *iolist,
|
||||
char **cmd, int *typelist,
|
||||
char *cmdbuf, int wrdcnt, uchar **preparse_list, int *next_word)
|
||||
char **cmd, int *typelist, char *cmdbuf, size_t cmdlen,
|
||||
int wrdcnt, uchar **preparse_list, int *next_word)
|
||||
{
|
||||
objnum verb;
|
||||
objnum iobj;
|
||||
@ -2776,7 +2776,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
/* disambiguate the direct object list, now that we can */
|
||||
if (vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT,
|
||||
PRP_VALIDDO, voctplvd(tpl), cmd, MCMONINV,
|
||||
actor, verb, prep, cmdbuf, FALSE))
|
||||
actor, verb, prep, cmdbuf, cmdlen, FALSE))
|
||||
{
|
||||
err = -1;
|
||||
goto exit_error;
|
||||
@ -2880,7 +2880,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
PRP_DODEFAULT, PRP_VALIDDO,
|
||||
voctplvd(tpl), cmd, MCMONINV,
|
||||
actor, verb, prep, cmdbuf,
|
||||
FALSE))
|
||||
cmdlen, FALSE))
|
||||
{
|
||||
err = -1;
|
||||
goto exit_error;
|
||||
@ -3058,7 +3058,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
/* disambiguate the direct object list */
|
||||
if (vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT,
|
||||
PRP_VALIDDO, voctplvd(tpl), cmd, otherobj,
|
||||
actor, verb, prep, cmdbuf, FALSE))
|
||||
actor, verb, prep, cmdbuf, cmdlen, FALSE))
|
||||
{
|
||||
err = -1;
|
||||
goto exit_error;
|
||||
@ -3083,7 +3083,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
/* disambiguate the indirect object list */
|
||||
if (vocdisambig(ctx, iolist1, iolist, PRP_IODEFAULT,
|
||||
PRP_VALIDIO, voctplvi(tpl), cmd, otherobj,
|
||||
actor, verb, prep, cmdbuf, FALSE))
|
||||
actor, verb, prep, cmdbuf, cmdlen, FALSE))
|
||||
{
|
||||
err = -1;
|
||||
goto exit_error;
|
||||
@ -3107,7 +3107,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
if (!(tplflags & VOCTPLFLG_DOBJ_FIRST)
|
||||
&& vocdisambig(ctx, dolist1, dolist, PRP_DODEFAULT,
|
||||
PRP_VALIDDO, voctplvd(tpl), cmd, otherobj,
|
||||
actor, verb, prep, cmdbuf, FALSE))
|
||||
actor, verb, prep, cmdbuf, cmdlen, FALSE))
|
||||
{
|
||||
err = -1;
|
||||
goto exit_error;
|
||||
@ -3582,7 +3582,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
* new command line - copy the new text to the command
|
||||
* buffer, set the 'redo' flag, and give up
|
||||
*/
|
||||
strcpy(cmdbuf, exenewcmd);
|
||||
Common::strcpy_s(cmdbuf, cmdlen, exenewcmd);
|
||||
ctx->voccxredo = TRUE;
|
||||
VOC_RETVAL(ctx, save_sp, 1);
|
||||
}
|
||||
@ -3613,7 +3613,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
|
||||
/* get the types */
|
||||
exenewlist[cnt] = nullptr;
|
||||
if (vocgtyp(ctx, exenewlist, exenewtype, cmdbuf))
|
||||
if (vocgtyp(ctx, exenewlist, exenewtype, cmdbuf, cmdlen))
|
||||
{
|
||||
/*
|
||||
* clear the unknown word count so that we fail with
|
||||
@ -3661,7 +3661,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
|| (exenewlist[next] && !vocspec(exenewlist[next], VOCW_THEN)
|
||||
&& *exenewlist[next] != '\0'))
|
||||
{
|
||||
strcpy(cmdbuf, exenewcmd);
|
||||
Common::strcpy_s(cmdbuf, cmdlen, exenewcmd);
|
||||
ctx->voccxredo = TRUE;
|
||||
VOC_RETVAL(ctx, save_sp, 1);
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname,
|
||||
* same directory that contains the .GAM file
|
||||
*/
|
||||
if (base_name != nullptr)
|
||||
strcpy(resname, base_name);
|
||||
Common::strcpy_s(resname, base_name);
|
||||
else
|
||||
resname[0] = '\0';
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ void linfnam(lindef *lin, char *buf)
|
||||
{
|
||||
# define linf ((linfdef *)lin)
|
||||
|
||||
strcpy(buf, linf->linfnam);
|
||||
Common::strcpy_s(buf, OSFNMAX, linf->linfnam);
|
||||
|
||||
# undef linf
|
||||
}
|
||||
|
@ -57,8 +57,9 @@ void mcsini(mcscxdef *ctx, mcmcx1def *gmemctx, ulong maxsiz,
|
||||
* have to retain the original copy (in case it's on the stack)
|
||||
*/
|
||||
if (swapfilename != nullptr) {
|
||||
ctx->mcscxfname = (char *)mchalo(errctx, (strlen(swapfilename) + 1), "mcsini");
|
||||
strcpy(ctx->mcscxfname, swapfilename);
|
||||
size_t ln = strlen(swapfilename) + 1;
|
||||
ctx->mcscxfname = (char *)mchalo(errctx, ln, "mcsini");
|
||||
Common::strcpy_s(ctx->mcscxfname, ln, swapfilename);
|
||||
} else {
|
||||
ctx->mcscxfname = nullptr;
|
||||
}
|
||||
|
@ -1895,7 +1895,7 @@ static int outformatlen_stream(out_stream_info *stream,
|
||||
}
|
||||
|
||||
/* convert the entire string to lower case for searching */
|
||||
strcpy(fmsbuf_srch, fmsbuf);
|
||||
Common::strcpy_s(fmsbuf_srch, fmsbuf);
|
||||
os_strlwr(fmsbuf_srch);
|
||||
|
||||
/* find the string in the format string table */
|
||||
@ -3144,7 +3144,7 @@ int tiologopn(tiocxdef *ctx, char *fn)
|
||||
return 1;
|
||||
|
||||
/* save the filename for later */
|
||||
strcpy(logfname, fn);
|
||||
Common::strcpy_s(logfname, fn);
|
||||
|
||||
/* open the new file */
|
||||
logfp = osfopwt(fn, OSFTLOG);
|
||||
|
@ -273,7 +273,7 @@ startover:
|
||||
if (voc->voccxredo && voc->voccxredobuf[0] != '\0')
|
||||
{
|
||||
/* copy the redo buffer into our internal buffer */
|
||||
strcpy(buf, voc->voccxredobuf);
|
||||
Common::strcpy_s(buf, voc->voccxredobuf);
|
||||
|
||||
/* we've consumed it now, so clear it out */
|
||||
voc->voccxredobuf[0] = '\0';
|
||||
|
@ -42,7 +42,7 @@ namespace TADS2 {
|
||||
/* dummy setup function */
|
||||
void supgnam(char *buf, tokthdef *tab, objnum sc)
|
||||
{
|
||||
strcpy(buf, "???");
|
||||
Common::strcpy_s(buf, TOKNAMMAX + 1, "???");
|
||||
}
|
||||
|
||||
/* dummy file read functions */
|
||||
@ -571,7 +571,7 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[],
|
||||
*/
|
||||
if (osfacc(infile))
|
||||
{
|
||||
strcpy(inbuf, infile);
|
||||
Common::strcpy_s(inbuf, infile);
|
||||
os_defext(inbuf, "gam");
|
||||
infile = inbuf;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ void TADS2::runGame() {
|
||||
os_instbrk(true);
|
||||
|
||||
char name[255];
|
||||
strcpy(name, getFilename().c_str());
|
||||
Common::strcpy_s(name, getFilename().c_str());
|
||||
char *argv[2] = { nullptr, name };
|
||||
|
||||
trdmain(2, argv, nullptr, ".sav");
|
||||
|
@ -372,7 +372,7 @@ int voctok(voccxdef *ctx, char *cmd, char *outbuf,
|
||||
char **wrd, int lower, int cvt_ones, int show_errors);
|
||||
|
||||
/* get types for a word list */
|
||||
int vocgtyp(voccxdef *ctx, char **cmd, int *types, char *orgbuf);
|
||||
int vocgtyp(voccxdef *ctx, char **cmd, int *types, char *orgbuf, size_t orgbuflen);
|
||||
|
||||
/* execute a player command */
|
||||
int voccmd(voccxdef *ctx, char *cmd, uint cmdlen);
|
||||
@ -382,7 +382,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
prpnum defprop, prpnum accprop, prpnum verprop,
|
||||
char *cmd[], objnum otherobj, objnum cmdActor,
|
||||
objnum cmdVerb, objnum cmdPrep, char *cmdbuf,
|
||||
int silent);
|
||||
size_t cmdlen, int silent);
|
||||
|
||||
/* display a multiple-object prefix */
|
||||
void voc_multi_prefix(voccxdef *ctx, objnum objn,
|
||||
@ -392,8 +392,8 @@ void voc_multi_prefix(voccxdef *ctx, objnum objn,
|
||||
/* low-level executor */
|
||||
int execmd(voccxdef *ctx, objnum actor, objnum prep,
|
||||
char *vverb, char *vprep, vocoldef *dolist, vocoldef *iolist,
|
||||
char **cmd, int *typelist,
|
||||
char *cmdbuf, int wrdcnt, uchar **preparse_list, int *next_start);
|
||||
char **cmd, int *typelist, char *cmdbuf, size_t cmdlen,
|
||||
int wrdcnt, uchar **preparse_list, int *next_start);
|
||||
|
||||
/* recursive command execution */
|
||||
int execmd_recurs(voccxdef *ctx, objnum actor, objnum verb,
|
||||
|
@ -1613,7 +1613,7 @@ static char *voc_read_oops(voccxdef *ctx, char *oopsbuf, size_t oopsbuflen,
|
||||
* figure out what parts of speech are associated with each
|
||||
* word in a tokenized command list
|
||||
*/
|
||||
int vocgtyp(voccxdef *ctx, char *cmd[], int types[], char *orgbuf)
|
||||
int vocgtyp(voccxdef *ctx, char *cmd[], int types[], char *orgbuf, size_t orgbuflen)
|
||||
{
|
||||
int cur;
|
||||
int t;
|
||||
@ -1800,7 +1800,7 @@ startover:
|
||||
* this must be a brand new command. Replace the
|
||||
* original command with the new command.
|
||||
*/
|
||||
strcpy(orgbuf, oopsbuf);
|
||||
Common::strcpy_s(orgbuf, orgbuflen, oopsbuf);
|
||||
|
||||
/*
|
||||
* forget we had an unknown word so that we're sure
|
||||
@ -1852,7 +1852,7 @@ startover:
|
||||
if (t & (1 << i))
|
||||
{
|
||||
if (cnt) *p++ = ',';
|
||||
strcpy(p, type_names[i]);
|
||||
Common::strcpy_s(p, sizeof(buf) - (p - buf), type_names[i]);
|
||||
p += strlen(p);
|
||||
++cnt;
|
||||
}
|
||||
@ -2202,7 +2202,7 @@ static void vocaddof(voccxdef *ctx, char *buf)
|
||||
buf[len + oldlen] = '\0';
|
||||
}
|
||||
else
|
||||
strcat(buf, "of");
|
||||
Common::strcat_s(buf, VOCBUFSIZ, "of");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@ -2421,13 +2421,13 @@ void voc_make_obj_name(voccxdef *ctx, char *namebuf, char *cmd[],
|
||||
if (voc_check_special(ctx, cmd[i], VOCW_OF))
|
||||
vocaddof(ctx, namebuf);
|
||||
else
|
||||
strcat(namebuf, cmd[i]);
|
||||
Common::strcat_s(namebuf, VOCBUFSIZ, cmd[i]);
|
||||
|
||||
if (cmd[i][strlen(cmd[i])-1] == '.' && i + 1 < lastwrd)
|
||||
strcat(namebuf, "\\");
|
||||
Common::strcat_s(namebuf, VOCBUFSIZ, "\\");
|
||||
|
||||
if (i + 1 < lastwrd)
|
||||
strcat(namebuf, " ");
|
||||
Common::strcat_s(namebuf, VOCBUFSIZ, " ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -4137,7 +4137,7 @@ void voc_parse_disambig(voccxdef *ctx)
|
||||
/* disambiguate the noun list */
|
||||
err = vocdisambig(&ctx_copy, outlist, inlist,
|
||||
defprop, accprop, verprop, cmd,
|
||||
otherobj, actor, verb, prep, cmdbuf, silent);
|
||||
otherobj, actor, verb, prep, cmdbuf, VOCBUFSIZ, silent);
|
||||
|
||||
/*
|
||||
* If the error was VOCERR(2) - unknown word - check the input list
|
||||
@ -4212,7 +4212,7 @@ void voc_parse_disambig(voccxdef *ctx)
|
||||
ctx_copy.voccxredo = TRUE;
|
||||
|
||||
/* copy the response into the command buffer */
|
||||
strcpy(cmdbuf, oopsbuf);
|
||||
Common::strcpy_s(cmdbuf, VOCBUFSIZ, oopsbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4262,7 +4262,7 @@ void voc_parse_disambig(voccxdef *ctx)
|
||||
if (i == unk_idx)
|
||||
{
|
||||
/* insert the replacement text */
|
||||
strcpy(p, rpl_text);
|
||||
Common::strcpy_s(p, VOCBUFSIZ - (p - cmdbuf), rpl_text);
|
||||
}
|
||||
else if (*cmd[i] == '"')
|
||||
{
|
||||
@ -4314,7 +4314,7 @@ void voc_parse_disambig(voccxdef *ctx)
|
||||
else
|
||||
{
|
||||
/* copy this word */
|
||||
strcpy(p, cmd[i]);
|
||||
Common::strcpy_s(p, VOCBUFSIZ - (p - cmdbuf), cmd[i]);
|
||||
}
|
||||
|
||||
/* move past this token */
|
||||
@ -4456,7 +4456,7 @@ void voc_parse_replace_cmd(voccxdef *ctx)
|
||||
* value is nonzero, then that object is the actor.
|
||||
*/
|
||||
static objnum vocgetactor(voccxdef *ctx, char *cmd[], int typelist[],
|
||||
int cur, int *next, char *cmdbuf)
|
||||
int cur, int *next, char *cmdbuf, size_t cmdlen)
|
||||
{
|
||||
int l;
|
||||
vocoldef *nounlist;
|
||||
@ -4501,7 +4501,7 @@ static objnum vocgetactor(voccxdef *ctx, char *cmd[], int typelist[],
|
||||
/* disambiguate it using the selected properties */
|
||||
if (vocdisambig(ctx, actlist, nounlist, PRP_DODEFAULT, valprop,
|
||||
verprop, cmd, MCMONINV, ctx->voccxme,
|
||||
ctx->voccxvtk, MCMONINV, cmdbuf, FALSE))
|
||||
ctx->voccxvtk, MCMONINV, cmdbuf, cmdlen, FALSE))
|
||||
{
|
||||
/*
|
||||
* if we have an unknown word in the list, assume for the
|
||||
@ -5246,7 +5246,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
prpnum defprop, prpnum accprop, prpnum verprop,
|
||||
char *cmd[], objnum otherobj, objnum cmdActor,
|
||||
objnum cmdVerb, objnum cmdPrep, char *cmdbuf,
|
||||
int silent)
|
||||
size_t cmdlen, int silent)
|
||||
{
|
||||
int inpos;
|
||||
int outpos;
|
||||
@ -5436,7 +5436,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
{
|
||||
err = vocdisambig(ctx, exclist2, exclist, defprop, accprop,
|
||||
verprop, cmd, otherobj, cmdActor,
|
||||
cmdVerb, cmdPrep, cmdbuf, silent);
|
||||
cmdVerb, cmdPrep, cmdbuf, cmdlen, silent);
|
||||
if (err != 0)
|
||||
goto done;
|
||||
|
||||
@ -5985,17 +5985,17 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
{
|
||||
/* quote the space if the last word ended with '.' */
|
||||
if (p[strlen(p)-1] == '.')
|
||||
strcat(usrobj, "\\");
|
||||
Common::strcat_s(usrobj, VOCBUFSIZ, "\\");
|
||||
|
||||
/* add the space */
|
||||
strcat(usrobj, " ");
|
||||
Common::strcat_s(usrobj, VOCBUFSIZ, " ");
|
||||
}
|
||||
|
||||
/* add the current word, or "of" if it's "of" */
|
||||
if (voc_check_special(ctx, p, VOCW_OF))
|
||||
vocaddof(ctx, usrobj);
|
||||
else
|
||||
strcat(usrobj, p);
|
||||
Common::strcat_s(usrobj, VOCBUFSIZ, p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6676,7 +6676,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
(int)VOCBUFSIZ, 2) == VOCREAD_REDO)
|
||||
{
|
||||
/* they want to treat the input as a new command */
|
||||
strcpy(cmdbuf, disnewbuf);
|
||||
Common::strcpy_s(cmdbuf, cmdlen, disnewbuf);
|
||||
ctx->voccxunknown = 0;
|
||||
ctx->voccxredo = TRUE;
|
||||
err = VOCERR(43);
|
||||
@ -6722,14 +6722,14 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
|
||||
/* tokenize the sentence */
|
||||
diswordlist[wrdcnt] = nullptr;
|
||||
if (vocgtyp(ctx, diswordlist, distypelist, cmdbuf)
|
||||
if (vocgtyp(ctx, diswordlist, distypelist, cmdbuf, cmdlen)
|
||||
|| ctx->voccxunknown != 0)
|
||||
{
|
||||
/*
|
||||
* there's an unknown word or other problem - retry
|
||||
* the input as an entirely new command
|
||||
*/
|
||||
strcpy(cmdbuf, disnewbuf);
|
||||
Common::strcpy_s(cmdbuf, cmdlen, disnewbuf);
|
||||
ctx->voccxunknown = 0;
|
||||
ctx->voccxredo = TRUE;
|
||||
err = VOCERR(2);
|
||||
@ -7005,7 +7005,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
* replace the entire adjective
|
||||
* phrase with "such"
|
||||
*/
|
||||
strcpy(newobj, "such");
|
||||
Common::strcpy_s(newobj, VOCBUFSIZ, "such");
|
||||
|
||||
/*
|
||||
* stop here - don't add any
|
||||
@ -7017,16 +7017,16 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
|
||||
/* add a space if we have a prior word */
|
||||
if (newobj[0] != '\0')
|
||||
strcat(newobj, " ");
|
||||
Common::strcat_s(newobj, VOCBUFSIZ, " ");
|
||||
|
||||
/* add this word */
|
||||
strcat(newobj, p);
|
||||
Common::strcat_s(newobj, VOCBUFSIZ, p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no noun phrase found */
|
||||
strcpy(newobj, "such");
|
||||
Common::strcpy_s(newobj, VOCBUFSIZ, "such");
|
||||
}
|
||||
|
||||
/* didn't find anything - complain and give up */
|
||||
@ -7067,7 +7067,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist,
|
||||
}
|
||||
|
||||
/* retry as an entire new command */
|
||||
strcpy(cmdbuf, disnewbuf);
|
||||
Common::strcpy_s(cmdbuf, cmdlen, disnewbuf);
|
||||
ctx->voccxunknown = 0;
|
||||
ctx->voccxredo = TRUE;
|
||||
err = VOCERR(43);
|
||||
@ -7112,7 +7112,7 @@ done:
|
||||
static int vocready(voccxdef *ctx, char *cmd[], int *typelist, int cur,
|
||||
objnum cmdActor, objnum cmdPrep, char *vverb, char *vprep,
|
||||
vocoldef *dolist, vocoldef *iolist, int *errp,
|
||||
char *cmdbuf, int first_word, uchar **preparse_list,
|
||||
char *cmdbuf, size_t cmdlen, int first_word, uchar **preparse_list,
|
||||
int *next_start)
|
||||
{
|
||||
if (cur != -1
|
||||
@ -7130,14 +7130,14 @@ static int vocready(voccxdef *ctx, char *cmd[], int *typelist, int cur,
|
||||
|
||||
*errp = execmd(ctx, cmdActor, cmdPrep, vverb, vprep, dolist, iolist,
|
||||
&cmd[first_word], &typelist[first_word],cmdbuf,
|
||||
cur - first_word, preparse_list, next_start);
|
||||
cmdlen, cur - first_word, preparse_list, next_start);
|
||||
return(TRUE);
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* execute a single command */
|
||||
static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, size_t cmdlen,
|
||||
objnum *cmdActorp, int first)
|
||||
{
|
||||
int cur;
|
||||
@ -7192,7 +7192,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
memset(typelist, 0, VOCBUFSIZ*sizeof(typelist[0]));
|
||||
|
||||
/* get the types of the words in the command */
|
||||
if (vocgtyp(ctx, cmd, typelist, cmdbuf))
|
||||
if (vocgtyp(ctx, cmd, typelist, cmdbuf, cmdlen))
|
||||
{
|
||||
retval = 1;
|
||||
goto done;
|
||||
@ -7291,7 +7291,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
cmd[cnt] = nullptr;
|
||||
|
||||
/* generate the type list for the new list */
|
||||
if (vocgtyp(ctx, cmd, typelist, cmdbuf))
|
||||
if (vocgtyp(ctx, cmd, typelist, cmdbuf, cmdlen))
|
||||
{
|
||||
/* return an error */
|
||||
retval = 1;
|
||||
@ -7354,7 +7354,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
preparseCmd_stat.active = FALSE;
|
||||
|
||||
/* get the type list for the original list again */
|
||||
if (vocgtyp(ctx, cmd, typelist, cmdbuf))
|
||||
if (vocgtyp(ctx, cmd, typelist, cmdbuf, cmdlen))
|
||||
{
|
||||
/* return the error */
|
||||
retval = 1;
|
||||
@ -7382,7 +7382,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
|
||||
{
|
||||
/* look for an explicit actor in the command */
|
||||
if ((o = vocgetactor(ctx, cmd, typelist, cur, &next, cmdbuf))
|
||||
if ((o = vocgetactor(ctx, cmd, typelist, cur, &next, cmdbuf, cmdlen))
|
||||
!= MCMONINV)
|
||||
{
|
||||
/* skip the actor noun phrase in the input */
|
||||
@ -7432,7 +7432,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
/* execute if the command is just a verb */
|
||||
if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep,
|
||||
vverb, vprep, dolist, iolist, &err, cmdbuf,
|
||||
first_word, &preparse_list, &next_start))
|
||||
cmdlen, first_word, &preparse_list, &next_start))
|
||||
continue;
|
||||
|
||||
/*
|
||||
@ -7447,7 +7447,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
vprep = cmd[cur++];
|
||||
if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep,
|
||||
vverb, vprep, dolist, iolist, &err, cmdbuf,
|
||||
first_word, &preparse_list, &next_start))
|
||||
cmdlen, first_word, &preparse_list, &next_start))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@ -7584,7 +7584,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
vverb, vprep,
|
||||
swapObj ? iolist : dolist,
|
||||
swapObj ? dolist : iolist,
|
||||
&err, cmdbuf, first_word, &preparse_list,
|
||||
&err, cmdbuf, cmdlen, first_word, &preparse_list,
|
||||
&next_start))
|
||||
continue;
|
||||
|
||||
@ -7630,7 +7630,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
if ((err = execmd(ctx, cmdActor, cmdPrep, vverb, vprep,
|
||||
dolist, iolist,
|
||||
&cmd[first_word], &typelist[first_word],
|
||||
cmdbuf, cur - first_word,
|
||||
cmdbuf, cmdlen, cur - first_word,
|
||||
&preparse_list, &next_start)) != 0)
|
||||
{
|
||||
retval = 1;
|
||||
@ -7701,7 +7701,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
|
||||
if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep,
|
||||
vverb, vprep, dolist, iolist, &err, cmdbuf,
|
||||
first_word, &preparse_list, &next_start))
|
||||
cmdlen, first_word, &preparse_list, &next_start))
|
||||
continue;
|
||||
else if ((typelist[cur] & VOCT_PREP) &&
|
||||
vocffw(ctx, vverb, vvlen, cmd[cur],
|
||||
@ -7711,7 +7711,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
vprep = cmd[cur++];
|
||||
if (vocready(ctx, cmd, typelist, cur, cmdActor,
|
||||
cmdPrep, vverb, vprep, dolist, iolist,
|
||||
&err, cmdbuf, first_word, &preparse_list,
|
||||
&err, cmdbuf, cmdlen, first_word, &preparse_list,
|
||||
&next_start))
|
||||
continue;
|
||||
else
|
||||
@ -7874,7 +7874,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
err = execmd(ctx, cmdActor, cmdPrep, vverb, vprep,
|
||||
iolist, dolist,
|
||||
&cmd[first_word], &typelist[first_word], cmdbuf,
|
||||
cur - first_word, &preparse_list, &next_start);
|
||||
cmdlen, cur - first_word, &preparse_list, &next_start);
|
||||
continue;
|
||||
}
|
||||
else if (cnt < 0)
|
||||
@ -7891,7 +7891,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf,
|
||||
done:
|
||||
/* copy back the command if we need to redo */
|
||||
if (ctx->voccxredo && cmdbuf != origcmdbuf)
|
||||
strcpy(origcmdbuf, cmdbuf);
|
||||
Common::strcpy_s(origcmdbuf, cmdlen, cmdbuf);
|
||||
|
||||
/* return the status */
|
||||
VOC_RETVAL(ctx, save_sp, retval);
|
||||
@ -8055,7 +8055,7 @@ int voccmd(voccxdef *ctx, char *cmd, uint cmdlen)
|
||||
for (;;)
|
||||
{
|
||||
/* try processing the command */
|
||||
if (voc1cmd(ctx, &wordlist[next], cmd, &cmdActor, first))
|
||||
if (voc1cmd(ctx, &wordlist[next], cmd, cmdlen, &cmdActor, first))
|
||||
{
|
||||
/*
|
||||
* If the unknown word flag is set, try the command
|
||||
|
@ -94,9 +94,9 @@ bool ZCodeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
|
||||
continue;
|
||||
}
|
||||
gameFile.seek(18);
|
||||
strcpy(&serial[0], "\"");
|
||||
Common::strcpy_s(&serial[0], sizeof(serial), "\"");
|
||||
gameFile.read(&serial[1], 6);
|
||||
strcpy(&serial[7], "\"");
|
||||
Common::strcpy_s(&serial[7], sizeof(serial)-7, "\"");
|
||||
} else {
|
||||
Blorb b(*file, INTERPRETER_ZCODE);
|
||||
Common::SeekableReadStream *f = b.createReadStreamForMember("game");
|
||||
@ -104,9 +104,9 @@ bool ZCodeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
|
||||
|
||||
if (!emptyBlorb) {
|
||||
f->seek(18);
|
||||
strcpy(&serial[0], "\"");
|
||||
Common::strcpy_s(&serial[0], sizeof(serial), "\"");
|
||||
f->read(&serial[1], 6);
|
||||
strcpy(&serial[7], "\"");
|
||||
Common::strcpy_s(&serial[7], sizeof(serial) - 7, "\"");
|
||||
delete f;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user