• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision3811 (tree)
Time2017-10-08 15:30:57
Authormagicant

Log Message

Adjust alias limit indexes on line continuation

The shift_index function is now external as the shift_aliaslist_index
function.

Change Summary

Incremental Difference

--- yash/trunk/parser.c (revision 3810)
+++ yash/trunk/parser.c (revision 3811)
@@ -658,6 +658,7 @@
658658 assert(ps->src.contents[index] == L'\\' &&
659659 ps->src.contents[index + 1] == L'\n');
660660 wb_remove(&ps->src, index, 2);
661+ shift_aliaslist_index(ps->aliases, index + 1, -2);
661662 ps->info->lineno++;
662663 if (ps->src.contents[index] == L'\0')
663664 read_more_input(ps);
--- yash/trunk/alias.c (revision 3810)
+++ yash/trunk/alias.c (revision 3811)
@@ -86,7 +86,6 @@
8686 __attribute__((nonnull));
8787 static bool is_after_blank(size_t i, size_t j, const xwcsbuf_T *buf)
8888 __attribute__((nonnull));
89-static void shift_index(aliaslist_T *list, size_t i, ptrdiff_t inc);
9089 static bool is_redir_fd(const wchar_t *s)
9190 __attribute__((nonnull,pure));
9291 static bool print_alias(const wchar_t *name, const alias_T *alias, bool prefix);
@@ -267,11 +266,13 @@
267266
268267 /* Increases the limit index by `inc' for each item whose index is larger
269268 * than `i'. */
270-void shift_index(aliaslist_T *list, size_t i, ptrdiff_t inc)
269+void shift_aliaslist_index(aliaslist_T *list, size_t i, ptrdiff_t inc)
271270 {
272271 while (list != NULL) {
273- if (list->limitindex > i)
272+ if (list->limitindex > i) {
273+ assert(inc >= 0 || (size_t) -inc <= list->limitindex);
274274 list->limitindex += inc;
275+ }
275276 list = list->next;
276277 }
277278 }
@@ -335,7 +336,8 @@
335336
336337 /* do substitution */
337338 wb_replace_force(buf, i, j - i, alias->value, alias->valuelen);
338- shift_index(*list, i, (ptrdiff_t) alias->valuelen - (ptrdiff_t) (j - i));
339+ shift_aliaslist_index(
340+ *list, i, (ptrdiff_t) alias->valuelen - (ptrdiff_t) (j - i));
339341
340342 /* add the alias to the list to track recursion */
341343 add_to_aliaslist(list, alias, i + alias->valuelen);
--- yash/trunk/alias.h (revision 3810)
+++ yash/trunk/alias.h (revision 3811)
@@ -37,6 +37,8 @@
3737 extern const wchar_t *get_alias_value(const wchar_t *aliasname)
3838 __attribute__((nonnull,pure));
3939 extern void destroy_aliaslist(struct aliaslist_T *list);
40+extern void shift_aliaslist_index(
41+ struct aliaslist_T *list, size_t i, ptrdiff_t inc);
4042 extern _Bool substitute_alias(
4143 struct xwcsbuf_T *restrict buf, size_t i,
4244 struct aliaslist_T **restrict list, substaliasflags_T flags)
Show on old repository browser