~ubuntu-branches/ubuntu/saucy/nano/saucy

« back to all changes in this revision

Viewing changes to src/nano.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach
  • Date: 2009-12-01 20:59:14 UTC
  • mfrom: (1.2.5 upstream) (17.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20091201205914-k0hydhsoysp7tahr
Tags: 2.2.0-1
* The "Televisió Sense Fronteres" release.
* New upstream stable release!
* Remove patch 10_tinybuildfix, applied upstream.
* Update 01_manpage_hyphens, as it's been applied only partially upstream.
* Remove French manpages from nano, until they are back in sync with the
  original versions (§12.1, Policy 3.8.3).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: nano.c 4422 2009-11-13 20:38:32Z astyanax $ */ 
 
1
/* $Id: nano.c 4449 2009-11-29 06:24:10Z astyanax $ */ 
2
2
/**************************************************************************
3
3
 *   nano.c                                                               *
4
4
 *                                                                        *
394
394
    /* If the top of the edit window was inside the old partition, put
395
395
     * it in range of current. */
396
396
    if (edittop_inside)
397
 
        edit_update(
398
 
#ifndef NANO_TINY
399
 
                ISSET(SMOOTH_SCROLL) ? NONE :
400
 
#endif
401
 
                CENTER);
 
397
        edit_update(NONE);
402
398
 
403
399
    /* Renumber starting with the beginning line of the old
404
400
     * partition. */
638
634
        if (filepart != NULL)
639
635
            unpartition_filestruct(&filepart);
640
636
 
641
 
        die_save_file(openfile->filename);
 
637
        die_save_file(openfile->filename
 
638
#ifndef NANO_TINY
 
639
                , openfile->current_stat
 
640
#endif
 
641
                );
642
642
    }
643
643
 
644
644
#ifdef ENABLE_MULTIBUFFER
651
651
 
652
652
            /* Save the current file buffer if it's been modified. */
653
653
            if (openfile->modified)
654
 
                die_save_file(openfile->filename);
 
654
                die_save_file(openfile->filename
 
655
#ifndef NANO_TINY
 
656
                        , openfile->current_stat
 
657
#endif
 
658
                        );
655
659
        }
656
660
    }
657
661
#endif
662
666
 
663
667
/* Save the current file under the name spacified in die_filename, which
664
668
 * is modified to be unique if necessary. */
665
 
void die_save_file(const char *die_filename)
 
669
void die_save_file(const char *die_filename
 
670
#ifndef NANO_TINY
 
671
        , struct stat *die_stat
 
672
#endif
 
673
        )
666
674
{
667
675
    char *retval;
668
676
    bool failed = TRUE;
691
699
        fprintf(stderr, _("\nBuffer not written: %s\n"),
692
700
                _("Too many backup files?"));
693
701
 
 
702
#ifndef NANO_TINY
 
703
    /* Try and chmod/chown the save file to the values of the original file, but
 
704
       dont worry if it fails because we're supposed to be bailing as fast
 
705
       as possible. */
 
706
    if (die_stat) {
 
707
        int shush;
 
708
        shush = chmod(retval, die_stat->st_mode);
 
709
        shush = chown(retval, die_stat->st_uid, die_stat->st_gid);
 
710
    }
 
711
#endif
 
712
 
694
713
    free(retval);
695
714
}
696
715
 
1165
1184
    disable_mouse_support();
1166
1185
#endif
1167
1186
 
1168
 
    /* Blank the screen, and move the cursor to the last line of the
1169
 
     * screen. */
1170
 
    erase();
 
1187
    /* Move the cursor to the last line of the screen. */
1171
1188
    move(LINES - 1, 0);
1172
 
    refresh();
 
1189
    endwin();
1173
1190
 
1174
1191
    /* Display our helpful message. */
1175
1192
    printf(_("Use \"fg\" to return to nano.\n"));
1612
1629
                                        && openfile->syntax->nmultis > 0) {
1613
1630
                                    reset_multis(openfile->current, FALSE);
1614
1631
                                }
 
1632
#endif
1615
1633
                                if (edit_refresh_needed) {
1616
1634
#ifdef DEBUG
1617
1635
                                    fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
1620
1638
                                    edit_refresh_needed = FALSE;
1621
1639
                                }
1622
1640
 
1623
 
#endif
1624
1641
                            }
1625
1642
                        }
1626
1643
                    }
1734
1751
void alloc_multidata_if_needed(filestruct *fileptr)
1735
1752
{
1736
1753
    if (!fileptr->multidata)
1737
 
        fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
 
1754
        fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
1738
1755
}
1739
1756
 
1740
1757
/* Precalculate the multi-line start and end regex info so we can speed up
2263
2280
#ifndef DISABLE_WRAPPING
2264
2281
            case 'w':
2265
2282
                SET(NO_WRAP);
 
2283
 
 
2284
                /* If both --fill and --nowrap are given on the command line,
 
2285
                   the last option wins, */
 
2286
                fill_used = FALSE;
 
2287
 
2266
2288
                break;
2267
2289
#endif
2268
2290
            case 'x':
2390
2412
#endif
2391
2413
#endif /* ENABLE_NANORC */
2392
2414
 
 
2415
#ifndef DISABLE_WRAPPING
 
2416
    /* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
 
2417
       if a --fill option was given on the command line. */ 
 
2418
    if (fill_used)
 
2419
        UNSET(NO_WRAP);
 
2420
#endif
 
2421
 
2393
2422
    /* If we're using bold text instead of reverse video text, set it up
2394
2423
     * now. */
2395
2424
    if (ISSET(BOLD_TEXT))