nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] Bugs with fixes, 1.0.8 and beyond!


From: Steven Kneizys
Subject: [Nano-devel] Bugs with fixes, 1.0.8 and beyond!
Date: Fri, 15 Feb 2002 23:50:23 -0800 (PST)

Greetings,

There is a small directory browsing problem that seems to affect
many nano versions, 1.0.8, 1.1.1, 1.1.6, tested.  If one is editing
a new buffer, does control-o, save as mydir/myfile.ext, then does
another control-o, control-t to browse, goes up two levels, there
is a seg fault.  The striponedir routine assumes that the topmost
character is a slash, if it is not it may erroneously return the 
very first letter of the path as the path!  I changed it to return
the '.' character as the path instead.  I also changed the do_browser
routine to recognize './..' as the path and change over to absolute
paths.  Here is a diff snippet that shows these changes:

*** files.c     Wed Oct 24 07:42:21 2001
--- ../nano-1.0.8.new/files.c   Sat Feb 16 01:42:53 2002
***************
*** 1116,1122 ****
--- 1116,1125 ----
      if (tmp != foo)
        *tmp = 0;
      else 
+     { /* SPK may need to make a 'default' path here */
+         if (*tmp != '/') *(tmp) = '.';
        *(tmp+1) = 0;
+     }
  
      return;
  }
***************
*** 1244,1249 ****
--- 1247,1260 ----
                statusbar(_("Can't move up a directory"));
            else
                path = mallocstrcpy(path, filelist[selected]);
+ 
+           /* SPK for '.' path, get the current path via getcwd */
+           if (!strcmp(path, "./..")) {
+               free(path);
+               path = getcwd(NULL, 0);
+               striponedir(path);                  
+               align(&path);
+           }
  
            st = filestat(path);
            if (S_ISDIR(st.st_mode)) {


(end snippet)

On the Compaq (Dec) OSF (gcc compiler) I noticed that Control-\ 
would result in a segfault.  I put in a call to raw() but I didn't
do a full POSIXV disable, anyway now it appears to work fine.

Also, in routine do_writeout there is a small feature problem.  With
-t and -o specified, the pico editor does not let the user choose a
file name with control-o, and I thought maybe we would not want to
either.  Just after the line

    answer = mallocstrcpy(answer, path);

near the top I added these lines to version 1.1.1 do that:

/* start SPK restricted temp mode, cannot change name */
    if ((operating_dir) && (ISSET(TEMP_OPT))) 
        if (filename[0]) {
            i = write_file(answer, 0, 0, 0);
            display_main_list();
            return i;
        }
/* end SPK restricted tool/temp mode, cannot change name */


Note: because of lib version problems on my Compaq, version 1.1.1 
was much easier to get going with -o feature by putting in all the
proper code from 1.1.6 ;-) but it looks like the above fix applies 
to 1.1.6 as well.

I have been making changes to check_operating_dir as well to make it
more friendly, I have it better than pico now and when I have a better
idea of what I am doing I will send it off.  

I tested all this on Linux (Slackware/686) and Digital UNIX V4.0D
(Compaq Alpha) and it all seems to be fine (gcc compiler on both.)

thanks!

Steve...


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]