Commit 6925bbd3 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

Added null_at()

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@140 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 81 additions and 76 deletions
+81 -76
...@@ -2,6 +2,8 @@ CVS code ...@@ -2,6 +2,8 @@ CVS code
- nano.c: - nano.c:
splice_node() splice_node()
- New function, abstracts linking in nodes. Fixes bug #36. - New function, abstracts linking in nodes. Fixes bug #36.
null_at()
- New function, nulls a string at a given index and realigns it.
delete_buffer() delete_buffer()
- Removed, same as free_filestruct(). - Removed, same as free_filestruct().
- search.c: - search.c:
......
...@@ -97,8 +97,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, ...@@ -97,8 +97,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
free(top->data); free(top->data);
top->data = tmpstr; top->data = tmpstr;
bot->data[bot_x] = 0; null_at(bot->data, bot_x);
align(&bot->data);
next = bot->next; next = bot->next;
/* We explicitly don't decrement totlines here because we don't snarf /* We explicitly don't decrement totlines here because we don't snarf
...@@ -369,8 +368,7 @@ int do_uncut_text(void) ...@@ -369,8 +368,7 @@ int do_uncut_text(void)
tmp->data = nmalloc(strlen(&current->data[current_x]) + 1); tmp->data = nmalloc(strlen(&current->data[current_x]) + 1);
strcpy(tmp->data, &current->data[current_x]); strcpy(tmp->data, &current->data[current_x]);
splice_node(current, tmp, current->next); splice_node(current, tmp, current->next);
current->data[current_x] = 0; null_at(current->data, current_x);
current->data = nrealloc(current->data, strlen(current->data) + 1);
current = current->next; current = current->next;
current_x = 0; current_x = 0;
placewewant = 0; placewewant = 0;
......
...@@ -307,6 +307,13 @@ void align(char **strp) ...@@ -307,6 +307,13 @@ void align(char **strp)
*strp = nrealloc(*strp, strlen(*strp) + 1); *strp = nrealloc(*strp, strlen(*strp) + 1);
} }
/* Null a string at a certain index and align it */
void null_at(char *data, int index)
{
data[index] = 0;
align(&data);
}
void usage(void) void usage(void)
{ {
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
...@@ -717,8 +724,7 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -717,8 +724,7 @@ void do_wrap(filestruct * inptr, char input_char)
down = 1; down = 1;
} }
inptr->data = nrealloc(inptr->data, current_x + 1); null_at(inptr->data, current_x);
inptr->data[current_x] = 0;
if (ISSET(MARK_ISSET) && (mark_beginbuf == inptr)) { if (ISSET(MARK_ISSET) && (mark_beginbuf == inptr)) {
mark_beginbuf = temp; mark_beginbuf = temp;
...@@ -765,9 +771,7 @@ void do_wrap(filestruct * inptr, char input_char) ...@@ -765,9 +771,7 @@ void do_wrap(filestruct * inptr, char input_char)
if (isspace(input_char) && (current_x == current_word_start)) { if (isspace(input_char) && (current_x == current_word_start)) {
current_x = current_word_start; current_x = current_word_start;
inptr->data = null_at(inptr->data, current_word_start);
nrealloc(inptr->data, current_word_start + 1);
inptr->data[current_word_start] = 0;
} else { } else {
while (isspace(inptr->data[i])) { while (isspace(inptr->data[i])) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-07-27 21:18-0400\n" "POT-Creation-Date: 2000-07-27 21:36-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -19,7 +19,7 @@ msgstr "" ...@@ -19,7 +19,7 @@ msgstr ""
msgid "add_to_cutbuffer called with inptr->data = %s\n" msgid "add_to_cutbuffer called with inptr->data = %s\n"
msgstr "" msgstr ""
#: cut.c:149 #: cut.c:148
msgid "Blew away cutbuffer =)\n" msgid "Blew away cutbuffer =)\n"
msgstr "" msgstr ""
...@@ -55,7 +55,7 @@ msgstr "" ...@@ -55,7 +55,7 @@ msgstr ""
msgid "File to insert [from ./] " msgid "File to insert [from ./] "
msgstr "" msgstr ""
#: files.c:272 files.c:296 files.c:486 nano.c:1146 #: files.c:272 files.c:296 files.c:486 nano.c:1150
msgid "Cancelled" msgid "Cancelled"
msgstr "" msgstr ""
...@@ -389,272 +389,272 @@ msgstr "" ...@@ -389,272 +389,272 @@ msgstr ""
msgid "free_node(): free'd last node.\n" msgid "free_node(): free'd last node.\n"
msgstr "" msgstr ""
#: nano.c:313 #: nano.c:320
msgid "" msgid ""
"Usage: nano [GNU long option] [option] +LINE <file>\n" "Usage: nano [GNU long option] [option] +LINE <file>\n"
"\n" "\n"
msgstr "" msgstr ""
#: nano.c:314 #: nano.c:321
msgid "Option\t\tLong option\t\tMeaning\n" msgid "Option\t\tLong option\t\tMeaning\n"
msgstr "" msgstr ""
#: nano.c:317 #: nano.c:324
msgid " -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n" msgid " -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n"
msgstr "" msgstr ""
#: nano.c:321 #: nano.c:328
msgid " -R\t\t--regexp\t\tUse regular expressions for search\n" msgid " -R\t\t--regexp\t\tUse regular expressions for search\n"
msgstr "" msgstr ""
#: nano.c:325 #: nano.c:332
msgid " -V \t\t--version\t\tPrint version information and exit\n" msgid " -V \t\t--version\t\tPrint version information and exit\n"
msgstr "" msgstr ""
#: nano.c:327 #: nano.c:334
msgid " -c \t\t--const\t\t\tConstantly show cursor position\n" msgid " -c \t\t--const\t\t\tConstantly show cursor position\n"
msgstr "" msgstr ""
#: nano.c:329 #: nano.c:336
msgid " -h \t\t--help\t\t\tShow this message\n" msgid " -h \t\t--help\t\t\tShow this message\n"
msgstr "" msgstr ""
#: nano.c:332 #: nano.c:339
msgid " -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n" msgid " -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n"
msgstr "" msgstr ""
#: nano.c:335 #: nano.c:342
msgid " -i \t\t--autoindent\t\tAutomatically indent new lines\n" msgid " -i \t\t--autoindent\t\tAutomatically indent new lines\n"
msgstr "" msgstr ""
#: nano.c:337 #: nano.c:344
msgid " -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite.\n" msgid " -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite.\n"
msgstr "" msgstr ""
#: nano.c:340 #: nano.c:347
msgid " -m \t\t--mouse\t\t\tEnable mouse\n" msgid " -m \t\t--mouse\t\t\tEnable mouse\n"
msgstr "" msgstr ""
#: nano.c:345 #: nano.c:352
msgid "" msgid ""
" -r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n" " -r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n"
msgstr "" msgstr ""
#: nano.c:347 #: nano.c:354
msgid " -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n" msgid " -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n"
msgstr "" msgstr ""
#: nano.c:349 #: nano.c:356
msgid " -s [prog] \t--speller=[prog]\tEnable alternate speller\n" msgid " -s [prog] \t--speller=[prog]\tEnable alternate speller\n"
msgstr "" msgstr ""
#: nano.c:351 #: nano.c:358
msgid " -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n" msgid " -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n"
msgstr "" msgstr ""
#: nano.c:353 #: nano.c:360
msgid " -v \t\t--view\t\t\tView (read only) mode\n" msgid " -v \t\t--view\t\t\tView (read only) mode\n"
msgstr "" msgstr ""
#: nano.c:355 #: nano.c:362
msgid " -w \t\t--nowrap\t\tDon't wrap long lines\n" msgid " -w \t\t--nowrap\t\tDon't wrap long lines\n"
msgstr "" msgstr ""
#: nano.c:357 #: nano.c:364
msgid " -x \t\t--nohelp\t\tDon't show help window\n" msgid " -x \t\t--nohelp\t\tDon't show help window\n"
msgstr "" msgstr ""
#: nano.c:359 #: nano.c:366
msgid " -z \t\t--suspend\t\tEnable suspend\n" msgid " -z \t\t--suspend\t\tEnable suspend\n"
msgstr "" msgstr ""
#: nano.c:361 #: nano.c:368
msgid " +LINE\t\t\t\t\tStart at line number LINE\n" msgid " +LINE\t\t\t\t\tStart at line number LINE\n"
msgstr "" msgstr ""
#: nano.c:363 #: nano.c:370
msgid "" msgid ""
"Usage: nano [option] +LINE <file>\n" "Usage: nano [option] +LINE <file>\n"
"\n" "\n"
msgstr "" msgstr ""
#: nano.c:364 #: nano.c:371
msgid "Option\t\tMeaning\n" msgid "Option\t\tMeaning\n"
msgstr "" msgstr ""
#: nano.c:366 #: nano.c:373
msgid " -T [num]\tSet width of a tab to num\n" msgid " -T [num]\tSet width of a tab to num\n"
msgstr "" msgstr ""
#: nano.c:368 #: nano.c:375
msgid " -R\t\tUse regular expressions for search\n" msgid " -R\t\tUse regular expressions for search\n"
msgstr "" msgstr ""
#: nano.c:369 #: nano.c:376
msgid " -V \t\tPrint version information and exit\n" msgid " -V \t\tPrint version information and exit\n"
msgstr "" msgstr ""
#: nano.c:370 #: nano.c:377
msgid " -c \t\tConstantly show cursor position\n" msgid " -c \t\tConstantly show cursor position\n"
msgstr "" msgstr ""
#: nano.c:371 #: nano.c:378
msgid " -h \t\tShow this message\n" msgid " -h \t\tShow this message\n"
msgstr "" msgstr ""
#: nano.c:373 #: nano.c:380
msgid " -k \t\tLet ^K cut from cursor to end of line\n" msgid " -k \t\tLet ^K cut from cursor to end of line\n"
msgstr "" msgstr ""
#: nano.c:375 #: nano.c:382
msgid " -i \t\tAutomatically indent new lines\n" msgid " -i \t\tAutomatically indent new lines\n"
msgstr "" msgstr ""
#: nano.c:377 #: nano.c:384
msgid " -l \t\tDon't follow symbolic links, overwrite.\n" msgid " -l \t\tDon't follow symbolic links, overwrite.\n"
msgstr "" msgstr ""
#: nano.c:380 #: nano.c:387
msgid " -m \t\tEnable mouse\n" msgid " -m \t\tEnable mouse\n"
msgstr "" msgstr ""
#: nano.c:384 #: nano.c:391
msgid " -r [#cols] \tSet fill cols to (wrap lines at) #cols\n" msgid " -r [#cols] \tSet fill cols to (wrap lines at) #cols\n"
msgstr "" msgstr ""
#: nano.c:385 #: nano.c:392
msgid " -s [prog] \tEnable alternate speller\n" msgid " -s [prog] \tEnable alternate speller\n"
msgstr "" msgstr ""
#: nano.c:386 #: nano.c:393
msgid " -p \t\tMake bottom 2 lines more Pico-like\n" msgid " -p \t\tMake bottom 2 lines more Pico-like\n"
msgstr "" msgstr ""
#: nano.c:387 #: nano.c:394
msgid " -t \t\tAuto save on exit, don't prompt\n" msgid " -t \t\tAuto save on exit, don't prompt\n"
msgstr "" msgstr ""
#: nano.c:388 #: nano.c:395
msgid " -v \t\tView (read only) mode\n" msgid " -v \t\tView (read only) mode\n"
msgstr "" msgstr ""
#: nano.c:389 #: nano.c:396
msgid " -w \t\tDon't wrap long lines\n" msgid " -w \t\tDon't wrap long lines\n"
msgstr "" msgstr ""
#: nano.c:390 #: nano.c:397
msgid " -x \t\tDon't show help window\n" msgid " -x \t\tDon't show help window\n"
msgstr "" msgstr ""
#: nano.c:391 #: nano.c:398
msgid " -z \t\tEnable suspend\n" msgid " -z \t\tEnable suspend\n"
msgstr "" msgstr ""
#: nano.c:392 #: nano.c:399
msgid " +LINE\t\tStart at line number LINE\n" msgid " +LINE\t\tStart at line number LINE\n"
msgstr "" msgstr ""
#: nano.c:399 #: nano.c:406
#, c-format #, c-format
msgid " nano version %s by Chris Allegretta (compiled %s, %s)\n" msgid " nano version %s by Chris Allegretta (compiled %s, %s)\n"
msgstr "" msgstr ""
#: nano.c:401 #: nano.c:408
msgid " Email: nano@asty.org\tWeb: http://www.asty.org/nano\n" msgid " Email: nano@asty.org\tWeb: http://www.asty.org/nano\n"
msgstr "" msgstr ""
#: nano.c:436 #: nano.c:443
msgid "Mark Set" msgid "Mark Set"
msgstr "" msgstr ""
#: nano.c:441 #: nano.c:448
msgid "Mark UNset" msgid "Mark UNset"
msgstr "" msgstr ""
#: nano.c:881 #: nano.c:885
#, c-format #, c-format
msgid "check_wrap called with inptr->data=\"%s\"\n" msgid "check_wrap called with inptr->data=\"%s\"\n"
msgstr "" msgstr ""
#: nano.c:932 #: nano.c:936
#, c-format #, c-format
msgid "current->data now = \"%s\"\n" msgid "current->data now = \"%s\"\n"
msgstr "" msgstr ""
#: nano.c:985 #: nano.c:989
#, c-format #, c-format
msgid "After, data = \"%s\"\n" msgid "After, data = \"%s\"\n"
msgstr "" msgstr ""
#: nano.c:1055 #: nano.c:1059
msgid "Error deleting tempfile, ack!" msgid "Error deleting tempfile, ack!"
msgstr "" msgstr ""
#: nano.c:1073 #: nano.c:1077
#, c-format #, c-format
msgid "Could not create a temporary filename: %s" msgid "Could not create a temporary filename: %s"
msgstr "" msgstr ""
#: nano.c:1096 #: nano.c:1100
#, c-format #, c-format
msgid "Could not invoke spell program \"%s\"" msgid "Could not invoke spell program \"%s\""
msgstr "" msgstr ""
#. Why 32512? I dont know! #. Why 32512? I dont know!
#: nano.c:1102 #: nano.c:1106
msgid "Could not invoke \"ispell\"" msgid "Could not invoke \"ispell\""
msgstr "" msgstr ""
#: nano.c:1115 #: nano.c:1119
msgid "Finished checking spelling" msgid "Finished checking spelling"
msgstr "" msgstr ""
#: nano.c:1133 #: nano.c:1137
msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? " msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
msgstr "" msgstr ""
#: nano.c:1256 #: nano.c:1260
msgid "Cannot resize top win" msgid "Cannot resize top win"
msgstr "" msgstr ""
#: nano.c:1258 #: nano.c:1262
msgid "Cannot move top win" msgid "Cannot move top win"
msgstr "" msgstr ""
#: nano.c:1260 #: nano.c:1264
msgid "Cannot resize edit win" msgid "Cannot resize edit win"
msgstr "" msgstr ""
#: nano.c:1262 #: nano.c:1266
msgid "Cannot move edit win" msgid "Cannot move edit win"
msgstr "" msgstr ""
#: nano.c:1264 #: nano.c:1268
msgid "Cannot resize bottom win" msgid "Cannot resize bottom win"
msgstr "" msgstr ""
#: nano.c:1266 #: nano.c:1270
msgid "Cannot move bottom win" msgid "Cannot move bottom win"
msgstr "" msgstr ""
#: nano.c:1743 #: nano.c:1747
msgid "Main: set up windows\n" msgid "Main: set up windows\n"
msgstr "" msgstr ""
#: nano.c:1765 #: nano.c:1769
msgid "Main: bottom win\n" msgid "Main: bottom win\n"
msgstr "" msgstr ""
#: nano.c:1771 #: nano.c:1775
msgid "Main: open file\n" msgid "Main: open file\n"
msgstr "" msgstr ""
#: nano.c:1844 #: nano.c:1848
#, c-format #, c-format
msgid "I got Alt-[-%c! (%d)\n" msgid "I got Alt-[-%c! (%d)\n"
msgstr "" msgstr ""
#: nano.c:1860 #: nano.c:1864
#, c-format #, c-format
msgid "I got Alt-%c! (%d)\n" msgid "I got Alt-%c! (%d)\n"
msgstr "" msgstr ""
......
...@@ -108,6 +108,7 @@ void die(char *msg, ...); ...@@ -108,6 +108,7 @@ void die(char *msg, ...);
void new_file(void); void new_file(void);
void new_magicline(void); void new_magicline(void);
void splice_node(filestruct *begin, filestruct *new, filestruct *end); void splice_node(filestruct *begin, filestruct *new, filestruct *end);
void null_at(char *data, int index)
int do_writeout_void(void), do_exit(void), do_gotoline_void(void); int do_writeout_void(void), do_exit(void), do_gotoline_void(void);
int do_insertfile(void), do_search(void), page_up(void), page_down(void); int do_insertfile(void), do_search(void), page_up(void), page_down(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment