diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..aac7860d7299 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.swp +*~ +*.orig +*.core +extern.h +*_def.h +version.h +tags +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000000..00f43283f022 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,190 @@ +cmake_minimum_required(VERSION 3.9) + +get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(is_multi_config) + set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING + "Semicolon separated list of supported configuration types") + mark_as_advanced(CMAKE_CONFIGURATION_TYPES) +elseif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_C_FLAGS) + message(WARNING "No CMAKE_BUILD_TYPE is selected") +endif() + +project(nvi2 C) + +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckCSourceCompiles) + +mark_as_advanced(CMAKE_INSTALL_PREFIX) + +option(USE_WIDECHAR "Enable wide character support" ON) +option(USE_ICONV "Enable iconv support" ON) + +add_compile_options(-fcolor-diagnostics) +add_compile_options($<$:-Wall>) +add_compile_options($<$:-Wno-parentheses>) +add_compile_options($<$:-Wno-uninitialized>) +add_compile_options($<$:-Wmissing-prototypes>) +add_compile_options($<$:-Wsystem-headers>) +add_compile_options($<$:-Wuninitialized>) +add_compile_options($<$:-Wno-dangling-else>) +add_compile_options(-Wstack-protector -fstack-protector) +add_compile_options(-Wstrict-aliasing -fstrict-aliasing) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +set(MAIN_PROTOS + cl/extern.h common/extern.h ex/extern.h vi/extern.h + common/options_def.h ex/ex_def.h ex/version.h) + +set(CL_SRCS + cl/cl_funcs.c cl/cl_main.c cl/cl_read.c cl/cl_screen.c cl/cl_term.c) + +set(COMMON_SRCS + common/conv.c common/cut.c common/delete.c common/encoding.c common/exf.c + common/key.c common/line.c common/log.c common/main.c common/mark.c + common/msg.c common/options.c common/options_f.c common/put.c + common/recover.c common/screen.c common/search.c common/seq.c + common/util.c) + +set(EX_SRCS + ex/ex.c ex/ex_abbrev.c ex/ex_append.c ex/ex_args.c ex/ex_argv.c ex/ex_at.c + ex/ex_bang.c ex/ex_cd.c ex/ex_cmd.c ex/ex_cscope.c ex/ex_delete.c + ex/ex_display.c ex/ex_edit.c ex/ex_equal.c ex/ex_file.c ex/ex_filter.c + ex/ex_global.c ex/ex_init.c ex/ex_join.c ex/ex_map.c ex/ex_mark.c + ex/ex_mkexrc.c ex/ex_move.c ex/ex_open.c ex/ex_preserve.c ex/ex_print.c + ex/ex_put.c ex/ex_quit.c ex/ex_read.c ex/ex_screen.c ex/ex_script.c + ex/ex_set.c ex/ex_shell.c ex/ex_shift.c ex/ex_source.c ex/ex_stop.c + ex/ex_subst.c ex/ex_tag.c ex/ex_txt.c ex/ex_undo.c ex/ex_usage.c + ex/ex_util.c ex/ex_version.c ex/ex_visual.c ex/ex_write.c ex/ex_yank.c + ex/ex_z.c) + +set(VI_SRCS + vi/getc.c vi/v_at.c vi/v_ch.c vi/v_cmd.c vi/v_delete.c vi/v_ex.c + vi/v_increment.c vi/v_init.c vi/v_itxt.c vi/v_left.c vi/v_mark.c + vi/v_match.c vi/v_paragraph.c vi/v_put.c vi/v_redraw.c vi/v_replace.c + vi/v_right.c vi/v_screen.c vi/v_scroll.c vi/v_search.c vi/v_section.c + vi/v_sentence.c vi/v_status.c vi/v_txt.c vi/v_ulcase.c vi/v_undo.c + vi/v_util.c vi/v_word.c vi/v_xchar.c vi/v_yank.c vi/v_z.c vi/v_zexit.c + vi/vi.c vi/vs_line.c vi/vs_msg.c vi/vs_refresh.c vi/vs_relative.c + vi/vs_smap.c vi/vs_split.c) + +set(REGEX_SRCS + regex/regcomp.c regex/regerror.c regex/regexec.c regex/regfree.c) + +# commands to generate the public headers +set(extract_protos sed -n 's/^ \\* PUBLIC: \\\(.*\\\)/\\1/p') +set(extract_version sed -n + 's/^.*version \\\([^\)]*\)\\\).*/\#define VI_VERSION \\\"\\1\\\"/p') + +add_custom_command(OUTPUT cl/extern.h + COMMAND ${extract_protos} ${CL_SRCS} > cl/extern.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${CL_SRCS}) +add_custom_command(OUTPUT common/extern.h + COMMAND ${extract_protos} ${COMMON_SRCS} > common/extern.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${COMMON_SRCS}) +add_custom_command(OUTPUT ex/extern.h + COMMAND ${extract_protos} ${EX_SRCS} > ex/extern.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${EX_SRCS}) +add_custom_command(OUTPUT vi/extern.h + COMMAND ${extract_protos} ${VI_SRCS} > vi/extern.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${VI_SRCS}) +add_custom_command(OUTPUT common/options_def.h + COMMAND awk -f common/options.awk + common/options.c > common/options_def.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS common/options.c) +add_custom_command(OUTPUT ex/ex_def.h + COMMAND awk -f ex/ex.awk ex/ex_cmd.c > ex/ex_def.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ex/ex_cmd.c) +add_custom_command(OUTPUT ex/version.h + COMMAND ${extract_version} README > ex/version.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS README) + +add_executable(nvi) +target_sources(nvi PRIVATE ${MAIN_PROTOS} ${CL_SRCS} ${COMMON_SRCS} + ${EX_SRCS} ${VI_SRCS}) +target_compile_definitions(nvi PRIVATE $<$:DEBUG> + $<$:COMLOG>) + +check_function_exists(openpty UTIL_IN_LIBC) +if(NOT UTIL_IN_LIBC) + find_library(UTIL_LIBRARY util) + target_link_libraries(nvi PRIVATE ${UTIL_LIBRARY}) +endif() + +check_function_exists(__b64_ntop RESOLV_IN_LIBC) +if(NOT RESOLV_IN_LIBC) + find_library(RESOLV_LIBRARY resolv) + target_link_libraries(nvi PRIVATE ${RESOLV_LIBRARY}) +endif() + +if(USE_WIDECHAR) + find_library(CURSES_LIBRARY NAMES ncursesw cursesw curses HINTS /usr/lib) + + # link to the wchar_t awared BSD libregex.a + add_library(regex STATIC) + target_sources(regex PRIVATE ${REGEX_SRCS}) + target_include_directories(regex PUBLIC regex) + target_compile_definitions(regex PUBLIC __REGEX_PRIVATE) + target_link_libraries(nvi PRIVATE regex) +else() + find_library(CURSES_LIBRARY NAMES ncurses curses HINTS /usr/lib) + target_compile_options(nvi PRIVATE -Wno-pointer-sign) +endif() + +target_link_libraries(nvi PRIVATE ${CURSES_LIBRARY}) + +if(USE_ICONV) + check_function_exists(__iconv ICONV_IN_LIBC) + if(NOT ICONV_IN_LIBC) + find_path(ICONV_INCLUDE_DIR iconv.h) + find_library(ICONV_LIBRARY iconv) + endif() + + # detect the prototype of iconv(3) + set(CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + set(CMAKE_REQUIRED_INCLUDES "${ICONV_INCLUDE_DIR}") + set(CMAKE_REQUIRED_LIBRARIES "${ICONV_LIBRARY}") + check_c_source_compiles(" + #include + int main() { + iconv_t conv = 0; + char* in = 0; + size_t ilen = 0; + char* out = 0; + size_t olen = 0; + iconv(conv, &in, &ilen, &out, &olen); + return 0; + } + " ICONV_TRADITIONAL) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}") + + target_include_directories(nvi PRIVATE ${ICONV_INCLUDE_DIR}) + target_link_libraries(nvi PRIVATE ${ICONV_LIBRARY}) +endif() + +check_include_files(libutil.h HAVE_LIBUTIL_H) +check_include_files(ncurses.h HAVE_NCURSES_H) +check_include_files(term.h HAVE_TERM_H) + +configure_file(files/config.h.in config.h) + +set(vi_cv_path_preserve /var/tmp/vi.recover/) +if(APPLE) + set(vi_cv_path_msgcat /usr/local/share/vi/catalog/) +else() + set(vi_cv_path_msgcat /usr/share/vi/catalog/) +endif() + +configure_file(files/pathnames.h.in pathnames.h) +configure_file(files/recover.in recover @ONLY) diff --git a/LICENSE b/LICENSE index c79151197da6..f9238465b7c9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,3 @@ -/*- - * $Id: LICENSE,v 8.18 2011/07/10 11:58:35 zy Exp $ - */ - The following are the copyrights and redistribution conditions that apply to this copy of the Vi software. diff --git a/README b/README index 26fcc167fc6f..8f61a97144be 100644 --- a/README +++ b/README @@ -1,6 +1,4 @@ -# $Id: README,v 9.2 2015/04/08 17:18:56 zy Exp $ - -This is version 2.1.3 (2015-04-08) of nex/nvi, a reimplementation of the ex/vi +This is version 2.2.0 (2020-08-01) of nex/nvi, a reimplementation of the ex/vi text editors originally distributed as part of the Fourth Berkeley Software Distribution (4BSD), by the University of California, Berkeley. @@ -8,12 +6,12 @@ The directory layout is as follows: LICENSE ....... Copyright, use and redistribution information. README ........ This file. - build ......... Build directory. catalog ....... Message catalogs; see catalog/README. cl ............ Vi interface to the curses(3) library. common ........ Code shared by ex and vi. - docs .......... Ex/vi documentation, both current and historic. ex ............ Ex source code. + files ......... Template files. + man ........... Ex/vi documentation. regex ......... Modified regex library with wide character support. vi ............ Vi source code. @@ -29,7 +27,7 @@ o Nvi was written by Keith Bostic, and the last version is 1.79. After that, The following acknowledgments were written by Keith Bostic: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -o This software is several years old and is the product of many folks' work. +o This software is several years old and is the product of many folks' work. This software was originally derived from software contributed to the University of California, Berkeley by Steve Kirkendall, the diff --git a/catalog/Makefile b/catalog/Makefile index 11e71cce6d7b..d9f7cc91456d 100644 --- a/catalog/Makefile +++ b/catalog/Makefile @@ -1,7 +1,5 @@ -# $Id: Makefile,v 9.0 2012/10/19 15:13:11 zy Exp $ - -CAT= dutch english french german polish ru_RU.KOI8-R spanish swedish \ - uk_UA.KOI8-U zh_CN.GB2312 +CAT= dutch english french german polish ru_RU.KOI8-R spanish \ + swedish tr_TR.ISO8859-9 tr_TR.UTF-8 uk_UA.KOI8-U zh_CN.GB2312 FILES= ../cl/*.c ../common/*.c ../ex/*.c ../vi/*.c all: dump ${CAT} @@ -33,7 +31,8 @@ ${CAT}: english.base CHK= dutch.check english.check french.check german.check \ polish.check ru_RU.KOI8-R.check spanish.check swedish.check \ - uk_UA.KOI8-U.check zh_CN.GB2312.check + tr_TR.ISO8859-9.check tr_TR.UTF-8.check uk_UA.KOI8-U.check \ + zh_CN.GB2312.check check: ${CHK} ${CHK}: ${CAT} @echo "... $@"; \ diff --git a/catalog/README b/catalog/README index 42a728afbe2e..14337c7c5981 100644 --- a/catalog/README +++ b/catalog/README @@ -1,5 +1,3 @@ -# $Id: README,v 9.0 2012/10/19 17:06:15 zy Exp $ - Generally, all non-system error and informational messages in nvi are catalog messages, i.e. they can be tailored to a specific langauge. Command strings, usage strings, system errors and other 'known text' diff --git a/catalog/dump.c b/catalog/dump.c index 585a6d908e41..ef893d647edf 100644 --- a/catalog/dump.c +++ b/catalog/dump.c @@ -27,10 +27,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char sccsid[] = "$Id: dump.c,v 8.2 2011/07/14 00:05:25 zy Exp $"; -#endif /* not lint */ - #include #include diff --git a/catalog/tr_TR.ISO8859-9.base b/catalog/tr_TR.ISO8859-9.base new file mode 100644 index 000000000000..a591974e34d8 --- /dev/null +++ b/catalog/tr_TR.ISO8859-9.base @@ -0,0 +1,304 @@ +002 "Satýr uzunluðu taþýmý" +003 "%lu numaralý satýr silinemiyor" +004 "%lu numaralý satýra iliþtirilemiyor" +005 "%lu numaralý satýrda ekleme yapýlamýyor" +006 "%lu numaralý satýr kaydedilemiyor" +007 "Son satýr alýnamýyor" +008 "Hata: %lu numaralý satýr okunamýyor" +009 "Günlük dosyasý" +010 "Günlükleme gerçekleþtirilmiyor, geri alma olanaklý deðil" +011 "Geri alýnacak bir deðiþiklik yok" +012 "Günlükleme gerçekleþtirilmiyor, geri alma olanaklý deðil" +013 "Günlükleme gerçekleþtirilmiyor, ileri sarma olanaklý deðil" +014 "Yinelenecek bir deðiþiklik yok" +015 "%s/%d: Günlük kayýt hatasý" +016 "Vi'nin standart girdisi ve çýktýsý bir uçbirim olmalý" +017 "Ým %s: Ayarlanmamýþ" +018 "Ým %s: Satýr silinmiþ" +019 "Ým %s: Ýmleç konumu artýk yok" +020 "Hata: " +021 "yeni dosya +022 "adý deðiþti" +023 "deðiþtirildi" +024 "deðiþtirilmedi" +025 "KÝLÝDÝ AÇILDI" +026 "saltokunur" +027 "satýr %lu/%lu [%ld%%]" +028 "boþ dosya" +029 "%lu. satýr" +030 "%s dosyasý bir ileti kataloðu deðil" +031 "Öntanýmlý %s seçeneði ayarlanamadý" +032 "Kullaným: %s" +033 "set: %s seçeneði yok: 'set all' tüm seçenek deðerlerini verir" +034 "set: [no]%s seçeneði bir deðer almaz" +035 "set: %s seçeneði bir Boole deðeri deðil" +036 "set: %s seçeneði: %s" +037 "set: %s seçeneði: %s: Deðer taþýmý" +038 "set: %s seçeneði: %s izin verilmeyen bir sayý" +039 "set: %s seçeneði bir Boole deðeri deðil" +040 "Ekran sütun sayýsý çok küçük, þundan daha az: %d" +041 "Ekran sütun sayýsý çok büyük, þundan daha çok: %d" +042 "Ekran satýr sayýsý çok küçük, þundan daha az: %d" +043 "Ekran satýr sayýsý çok büyük, þundan daha çok: %d" +044 "Lisp seçeneði eklenmemiþ" +045 "Ýletiler kapatýlmamýþ: %s" +046 "Ýletiler açýlmamýþ: %s" +047 "%s seçeneði iki karakterli öbekler biçiminde olmalý" +053 "Baþlangýç arabelleði boþ" +054 "%s arabelleði boþ" +056 "Oturum baþarýsýz olursa deðiþiklikler kurtarýlamaz" +057 "Dosya, kurtarma için kopyalanýyor..." +058 "Koruma baþarýsýz oldu: %s" +059 "Oturum baþarýsýz olursa deðiþiklikler kurtarýlamaz" +060 "Dosya yedeklemesi baþarýsýz oldu: %s" +061 "Dosya, kurtarma için kopyalanýyor..." +062 "%u kullanýcýsý üzerine bilgi bulunamadý" +063 "Kurtarma dosyasý kilitlenemiyor" +065 "Kurtarma dosyasý" +066 "%s: Hatalý oluþturulmuþ kurtarma dosyasý" +067 "%s: Hatalý oluþturulmuþ kurtarma dosyasý" +068 "Kurtarýlacak %s adýnda sizce okunabilir bir dosya yok" +069 "Bu dosyanýn kurtarabileceðiniz eski sürümleri var" +070 "Kurtarabileceðiniz baþka dosyalar var" +071 "E-posta gönderilmedi: %s" +072 "Dosya boþ, aranacak bir þey yok" +073 "Dizgi bulunamadan dosyanýn sonuna eriþildi" +074 "Arama dizgisi yok" +075 "Dizgi bulunamadý" +076 "Dizgi bulunamadan dosyanýn baþýna eriþildi" +077 "Arama tamamlandý" +078 "Aranýyor..." +079 "Yazdýrýlamaz karakter bulunmadý" +080 "Bilinmeyen komut adý" +082 "%s: Komut ex kipinde kullanýlamaz" +083 "Sayým sýfýr olmayabilir" +084 "%s: Hatalý satýr belirtimi" +085 "Ýç sözdizim tablo hatasý (%s: %s)" +086 "Kullaným: %s" +087 "%s: Geçici arabellek salýverilmedi" +088 "Bayrak göreli konumu birinci satýrdan önceye" +089 "Bayrak göreli konumu dosya sonunu geçiyor" +090 "Erimli @, dosya/ekran deðiþtiðinde çalýþýr" +091 "Global/v komutu dosya/ekran deðiþtiðinde çalýþýr" +092 "Ex komutu baþarýsýz: Sýradaki komutlar çýkarýldý" +093 "Ex komutu baþarýsýz: Eþlemlenen düðmeler çýkarýldý" +094 "Ýkinci adres ilkinden daha küçük" +095 "Bir im adý saðlanmadý" +096 "\\ sonrasýnda / veya ? gelmiyor" +097 "Bir satýr numarasýna yapýlan baþvuru sayýsý sýfýrdan az" +098 "Bilinmeyen komut: %s" +099 "Adres deðeri taþýmý" +100 "Adres deðeri alttaþýmý" +101 "Ýzin verilmeyen adres birleþimi" +102 "Ýzin verilmeyen adres: Dosyada yalnýzca %lu satýr var" +103 "Ýzin verilmeyen adres: Dosya boþ" +104 "%s komutu bir 0 adresine izin vermiyor" +105 "Görüntülenecek kýsaltma yok" +106 "Kýsaltmalar bir \"sözcük\" karakteri ile bitmelidir" +107 "Kýsaltmalar sekme veya boþluk içeremez" +108 "Kýsaltmalar sonu dýþýnda sözcük/sözcük olmayan karakterleri karýþtýramaz" +109 "\"%s\" bir kýsaltma deðil" +110 "Vi komutu baþarýsýz: Eþlemlenen düðmeler çýkarýldý" +111 "Düzenlenecek baþka dosya yok" +112 "Öncesinde düzenlenecek baþka dosya yok" +113 "Öncesinde geri sarýlacak dosyalar yok" +114 "Görüntülenecek dosya yok" +115 "Öncesinde \"!\" ögesinin yerine geçecek bir komut yok" +116 "%% yerine geçecek bir dosya adý yok" +117 "# yerine geçecek bir dosya adý yok" +118 "Hata: execl: %s" +119 "Girdi/Çýktý hatasý: %s" +120 "Dosya son tam yazýmdan bu yana deðiþtirilmiþ; yazýn veya yok saymak için ! kullanýn" +121 "Ev dizini konumu bulunamýyor" +122 "Yeni þimdiki dizin: %s" +123 "Görüntülenecek kesilmiþ arabellek yok" +124 "%s komutu bir global veya v komutunun parçasý olarak kullanýlamaz" +128 "%s: kaynak alýnmýyor: Ýyesi siz veya kök deðil" +129 "%s: kaynak alýnmýyor: Ýyesi siz deðilsiniz" +130 "%s: kaynak alýnmýyor: Ýyesi dýþýnda baþka bir kullanýcý tarafýndan yazýlabilir" +131 "Uç uca eklenecek bir satýr yok" +132 "Girdi eþlem girdisi yok" +133 "Komut eþlem girdisi yok" +134 "%s yeniden eþlemlenemeyebilir" +135 "\"%s\" þu anda eþlemlenmemiþ" +136 "Ým adlarý tek bir karakter olmalýdýr" +137 "%s mevcut, yazýlmamýþ; yok saymak için ! kullanýn" +138 "Yeni exrc dosyasý: %s" +139 "Hedef satýrý taþýma erimi içinde" +140 "'open' komutu 'open' seçeneðinin ayarlý olmasýný gerektirir" +141 "'open' komutu henüz eklenmemiþ" +142 "Bu dosyanýn korunmasý olanaklý deðil" +143 "Dosya korundu" +144 "%s: Çok fazla dosya adýna geniþletilmiþ" +145 "Yalnýzca sýradan dosyalar ve adlandýrýlmýþ veri yollarý okunabilir" +146 "%s: Okuma kilidi kullanýlabilir deðildi" +147 "Okunuyor..." +148 "%s: %lu satýr, %lu karakter" +149 "Görüntülenecek arkaplan ekraný yok" +150 "'script' komutu yalnýzca vi kipinde kullanýlabilir" +151 "Çalýþtýrýlacak komut yok" +152 "'shiftwidth' seçeneði 0 olarak ayarlanmýþ" +153 "Sayým taþýmý" +154 "Sayým alttaþýmý" +155 "Düzenli ifade belirtilmiþ; r bayraðý anlamsýz" +156 "#, l ve p bayraklarý vi kipinde c bayraðý ile birlikte kullanýlamaz" +157 "Eþleþme bulunamadý" +158 "Önceden bir etiket girilmemiþ" +159 "Etiket yýðýnýnda %s sayýsýndan az girdi; :display t[ags] kullanýn" +160 "Etiket yýðýnýnda dönülecek bir %s dosyasý yok; :display t[ags] kullanýn" +161 "Sürdürmek için Enter'a basýn:" +162 "%s: Etiket bulunamadý" +163 "%s: %s içinde hasar görmüþ etiket" +164 "%s: Etiketin satýr numarasý dosya sonunu geçmiþ" +165 "Etiket yýðýný boþ" +166 "%s: Arama dizgisi bulunamadý" +167 "%d dosya daha düzenlenecek" +168 "%s arabelleði boþ" +169 "Deðiþikliði onayla? [n]" +170 "Yarýda kesildi" +171 "Öncesinde çalýþtýrýlacak arabellek yok" +172 "Öncesinde düzenli ifade yok" +173 "%s komutu bir dosyanýn halihazýrda okunmuþ olmasýný gerektirir" +174 "Kullaným: %s" +175 "'visual' komutu 'open' seçeneðinin ayarlanmýþ olmasýný gerektirir" +177 "Boþ dosya" +178 "Öncesinde F, f, T veya t aramasý yok" +179 "%s bulunamadý" +180 "Düzenlenecek dosya yok" +181 "Ýmleç bir sayýda deðil" +182 "Ortaya çýkan sayý çok büyük" +183 "Ortaya çýkan sayý çok küçük" +184 "Bu satýrda eþleþen karakter yok" +185 "Eþleþen karakter bulunamadý" +186 "Deðiþtirilecek karakter yok" +187 "Geçilecek baþka ekran yok" +188 "Arama dizgisinden, satýr ofsetinden ve/veya 'z' komutundan sonraki karakterler" +189 "Öncesinde arama dizgisi yok" +190 "Arama baþlanan konumda tamamlandý" +191 "Kýsaltma geniþleme sýnýrýný aþtý: Karakterler çýkarýldý" +192 "Ýzin verilmeyen karakter; giriþ için týrnak içine alýn" +193 "Halihazýrda eklemenin baþýnda" +194 "Silinecek baþka karakter yok" +195 "Hareket dosya sonunu geçti" +196 "Hareket satýr sonunu geçti" +197 "Ýmleç hareket ettirilmedi" +198 "Halihazýrda dosyanýn baþýnda" +199 "Hareket dosyanýn baþýný geçti" +200 "Halihazýrda ilk sütunda" +201 "Arabellekler komuttan önce belirtilmeli" +202 "Halihazýrda dosya sonunda" +203 "Halihazýrda satýr sonunda" +204 "%s bir vi komutu deðil" +205 "Kullaným: %s" +206 "Silinecek karakter yok" +207 "Q komutu ex uçbirim arabirimini gerektirir" +208 "Yinelenecek komut yok" +209 "Dosya boþ" +210 "%s bir hareket komutu olarak kullanýlamaz" +211 "Halihazýrda komut kipi içinde" +212 "Ýmleç bir sözcükte deðil" +214 "'windows' seçeneði deðeri çok büyük, en çok %u olabilir" +215 "Ýliþtir" +216 "Deðiþiklik yap" +217 "Komut" +218 "Ekle" +219 "Deðiþtir" +220 "Hareket ekran sonunu geçti" +221 "Hareket ekran baþýný geçti" +222 "Ekran bölünebilmesi için %d satýrdan daha geniþ olmalýdýr" +223 "Arkaplan ekraný yok" +224 "Arkaplanda %s dosyasýný düzenleyen bir ekran yok" +225 "Açýk olan tek ekranýnýzý arkaplana alamazsýnýz" +226 "Ekran yalnýzca %d satýra küçültülebilir" +227 "Ekran küçülemez" +228 "Ekran büyüyemez" +230 "Bu ekran askýya alýnamaz" +231 "Yarýda kesildi: Eþlemlenen düðmeler çýkarýldý" +232 "vi: Geçici arabellek salýverilmedi" +233 "Bu uçbirimde %s düðmesi yok" +234 "Yalnýzca bir arabellek belirtilebilir" +235 "Sayý þundan daha büyük: %lu" +236 "Yarýda kesildi" +237 "Geçici dosya oluþturulamýyor" +238 "Uyarý: %s sýradan bir dosya deðil" +239 "%s halihazýrda kilitlenmiþ, oturum saltokunur" +240 "%s: Kaldýr" +241 "%s: Kapat" +242 "%s: Kaldýr" +243 "%s: Kaldýr" +244 "Saltokunur dosya, yazýlmadý; yok saymak için ! kullanýn" +245 "Saltokunur dosya, yazýlmadý" +246 "%s mevcut, yazýlmadý; yok saymak için ! kullanýn" +247 "%s mevcut, yazýlmadý" +248 "Kýsmi dosya, yazýlmadý; yok saymak için ! kullanýn" +249 "Kýsmi dosya, yazýlmadý" +250 "%s: Dosya bu kopyadan daha önce deðiþtirilmiþ; yok saymak için ! kullanýn" +251 "%s: Dosya bu kopyadan daha önce deðiþtirilmiþ" +252 "%s: Yazým korumasý kullanýlabilir deðildi" +253 "Yazýlýyor..." +254 "%s: UYARI: DOSYA KIRPILMIÞ" +255 "Halihazýrda bu grubun ilk etiketinde" +256 "%s: Yeni dosya: %lu satýr, %lu karakter" +257 "%s: %lu satýr, %lu karakter" +258 "%s çok fazla dosya adýna geniþletilmiþ" +259 "%s: Sýradan bir dosya deðil" +260 "%s: Ýyesi siz deðilsiniz" +261 "%s: Ýyesi dýþýnda baþka bir kullanýcý tarafýndan da eriþilebilir" +262 "Dosya son tam yazýmdan bu yana deðiþtirilmiþ; yazýn veya yok saymak için ! kullanýn" +263 "Dosya son tam yazýmdan bu yana deðiþtirilmiþ; yazýn veya yok saymak için :edit! kullanýn" +264 "Dosya son tam yazýmdan bu yana deðiþtirilmiþ; yazýn veya yok saymak için ! kullanýn" +265 "Dosya geçici; çýkarsanýz deðiþiklikler atýlacaktýr" +266 "Dosya saltokunur, deðiþiklikler kendiliðinden yazýlmaz" +267 "Günlük yeniden baþlatýldý" +268 "Onayla? [ynq]" +269 "Sürdürmek için herhangi bir düðmeye basýn: " +270 "Sürdürmek için herhangi bir düðmeye basýn [ex komutu girmek için :]: " +271 "Sürdürmek için herhangi bir düðmeye basýn [çýkýþ için q]: " +272 "Bu biçim %s ex uçbirim arabirimini gerektirir" +273 "ex girdisi kipine giriliyor" +274 "Komut baþarýsýz, henüz bir dosya okunmadý." +275 " sürdür?" +276 "Beklenmedik karakter olayý" +277 "Beklenmedik dosya sonu olayý" +278 "Sorgu eþleþmesi bulunamadý" +279 "Beklenmedik yarýda kesme olayý" +281 "Beklenmedik yeniden boyama olayý" +282 "Halihazýrda bu grubun son etiketinde" +283 "%s komutu ex uçbirim arabirimini gerektirir" +284 "Bu biçim %s 'secure edit' seçeneði ayarlandýðýnda desteklenmez" +285 "Beklenmedik dizi olayý" +286 "Beklenmedik zaman aþýmý olayý" +288 "Bölünebilmesi için ekran %d sütundan daha geniþ olmalýdýr" +289 "Kabuk geniþletmeleri 'secure edit' seçeneði ayarlandýðýnda desteklenmez" +290 "%s komutu 'secure edit' seçeneði ayarlandýðýnda desteklenmez" +291 "set: %s seçeneði kapatýlamaz" +292 "Ekran çok küçük." +293 "eklendi" +294 "deðiþtirildi" +295 "silindi" +296 "uç uca eklendi" +297 "taþýndý" +298 "kaydýrýldý" +299 "kopyalandý" +300 "satýr" +301 "satýr" +303 "Dosya son yazýmdan bu yana deðiþtirilmiþ." +304 "Kabuk geniþletmesi baþarýsýz" +305 "Bir '%s' düzenleme seçeneði belirtilmedi" +307 "Çalýþtýrýlacak ex komutu yok" +308 "Bir komut çalýþtýrmak için , çýkmak için :q girin" +309 "Yardým için \"cscope help\" kullanýn" +310 "Çalýþan bir cscope baðlantýsý yok" +311 "%s: Bilinmeyen arama türü: Þunlardan bir tanesini kullanýn: %s" +312 "%d: Böyle bir cscope oturumu yok" +313 "set: %s seçeneði hiçbir zaman açýlamaz" +314 "set: %s seçeneði hiçbir zaman 0 olarak ayarlanamaz" +315 "%s: Ýliþtirildi: %lu satýr, %lu karakter" +316 "Beklenmedik yeniden boyutlandýrma olayý" +317 "Düzenlenecek %d dosya var" +319 "%d ekran arkaplana alýndý; onlarý listelemek için :display kullanýn" +320 "Bilinmeyen imleç konumu" +321 "Dosya kodlama dönüþtürmesi desteklenmiyor" +322 "Girdi kodlama dönüþtürmesi desteklenmiyor" +323 "Geçersiz girdi. Kýrpýldý." +324 "%d numaralý satýrda dönüþtürme hatasý" diff --git a/catalog/tr_TR.ISO8859-9.owner b/catalog/tr_TR.ISO8859-9.owner new file mode 100644 index 000000000000..2739e5bbfd61 --- /dev/null +++ b/catalog/tr_TR.ISO8859-9.owner @@ -0,0 +1 @@ +Emir SARI diff --git a/catalog/tr_TR.UTF-8.base b/catalog/tr_TR.UTF-8.base new file mode 100644 index 000000000000..9c27d4eb7423 --- /dev/null +++ b/catalog/tr_TR.UTF-8.base @@ -0,0 +1,304 @@ +002 "Satır uzunluÄŸu taşımı" +003 "%lu numaralı satır silinemiyor" +004 "%lu numaralı satıra iliÅŸtirilemiyor" +005 "%lu numaralı satırda ekleme yapılamıyor" +006 "%lu numaralı satır kaydedilemiyor" +007 "Son satır alınamıyor" +008 "Hata: %lu numaralı satır okunamıyor" +009 "Günlük dosyası" +010 "Günlükleme gerçekleÅŸtirilmiyor, geri alma olanaklı deÄŸil" +011 "Geri alınacak bir deÄŸiÅŸiklik yok" +012 "Günlükleme gerçekleÅŸtirilmiyor, geri alma olanaklı deÄŸil" +013 "Günlükleme gerçekleÅŸtirilmiyor, ileri sarma olanaklı deÄŸil" +014 "Yinelenecek bir deÄŸiÅŸiklik yok" +015 "%s/%d: Günlük kayıt hatası" +016 "Vi'nin standart girdisi ve çıktısı bir uçbirim olmalı" +017 "Ä°m %s: Ayarlanmamış" +018 "Ä°m %s: Satır silinmiÅŸ" +019 "Ä°m %s: Ä°mleç konumu artık yok" +020 "Hata: " +021 "yeni dosya +022 "adı deÄŸiÅŸti" +023 "deÄŸiÅŸtirildi" +024 "deÄŸiÅŸtirilmedi" +025 "KÄ°LÄ°DÄ° AÇILDI" +026 "saltokunur" +027 "satır %lu/%lu [%ld%%]" +028 "boÅŸ dosya" +029 "%lu. satır" +030 "%s dosyası bir ileti kataloÄŸu deÄŸil" +031 "Öntanımlı %s seçeneÄŸi ayarlanamadı" +032 "Kullanım: %s" +033 "set: %s seçeneÄŸi yok: 'set all' tüm seçenek deÄŸerlerini verir" +034 "set: [no]%s seçeneÄŸi bir deÄŸer almaz" +035 "set: %s seçeneÄŸi bir Boole deÄŸeri deÄŸil" +036 "set: %s seçeneÄŸi: %s" +037 "set: %s seçeneÄŸi: %s: DeÄŸer taşımı" +038 "set: %s seçeneÄŸi: %s izin verilmeyen bir sayı" +039 "set: %s seçeneÄŸi bir Boole deÄŸeri deÄŸil" +040 "Ekran sütun sayısı çok küçük, ÅŸundan daha az: %d" +041 "Ekran sütun sayısı çok büyük, ÅŸundan daha çok: %d" +042 "Ekran satır sayısı çok küçük, ÅŸundan daha az: %d" +043 "Ekran satır sayısı çok büyük, ÅŸundan daha çok: %d" +044 "Lisp seçeneÄŸi eklenmemiÅŸ" +045 "Ä°letiler kapatılmamış: %s" +046 "Ä°letiler açılmamış: %s" +047 "%s seçeneÄŸi iki karakterli öbekler biçiminde olmalı" +053 "BaÅŸlangıç arabelleÄŸi boÅŸ" +054 "%s arabelleÄŸi boÅŸ" +056 "Oturum baÅŸarısız olursa deÄŸiÅŸiklikler kurtarılamaz" +057 "Dosya, kurtarma için kopyalanıyor..." +058 "Koruma baÅŸarısız oldu: %s" +059 "Oturum baÅŸarısız olursa deÄŸiÅŸiklikler kurtarılamaz" +060 "Dosya yedeklemesi baÅŸarısız oldu: %s" +061 "Dosya, kurtarma için kopyalanıyor..." +062 "%u kullanıcısı üzerine bilgi bulunamadı" +063 "Kurtarma dosyası kilitlenemiyor" +065 "Kurtarma dosyası" +066 "%s: Hatalı oluÅŸturulmuÅŸ kurtarma dosyası" +067 "%s: Hatalı oluÅŸturulmuÅŸ kurtarma dosyası" +068 "Kurtarılacak %s adında sizce okunabilir bir dosya yok" +069 "Bu dosyanın kurtarabileceÄŸiniz eski sürümleri var" +070 "KurtarabileceÄŸiniz baÅŸka dosyalar var" +071 "E-posta gönderilmedi: %s" +072 "Dosya boÅŸ, aranacak bir ÅŸey yok" +073 "Dizgi bulunamadan dosyanın sonuna eriÅŸildi" +074 "Arama dizgisi yok" +075 "Dizgi bulunamadı" +076 "Dizgi bulunamadan dosyanın başına eriÅŸildi" +077 "Arama tamamlandı" +078 "Aranıyor..." +079 "Yazdırılamaz karakter bulunmadı" +080 "Bilinmeyen komut adı" +082 "%s: Komut ex kipinde kullanılamaz" +083 "Sayım sıfır olmayabilir" +084 "%s: Hatalı satır belirtimi" +085 "İç sözdizim tablo hatası (%s: %s)" +086 "Kullanım: %s" +087 "%s: Geçici arabellek salıverilmedi" +088 "Bayrak göreli konumu birinci satırdan önceye" +089 "Bayrak göreli konumu dosya sonunu geçiyor" +090 "Erimli @, dosya/ekran deÄŸiÅŸtiÄŸinde çalışır" +091 "Global/v komutu dosya/ekran deÄŸiÅŸtiÄŸinde çalışır" +092 "Ex komutu baÅŸarısız: Sıradaki komutlar çıkarıldı" +093 "Ex komutu baÅŸarısız: EÅŸlemlenen düğmeler çıkarıldı" +094 "Ä°kinci adres ilkinden daha küçük" +095 "Bir im adı saÄŸlanmadı" +096 "\\ sonrasında / veya ? gelmiyor" +097 "Bir satır numarasına yapılan baÅŸvuru sayısı sıfırdan az" +098 "Bilinmeyen komut: %s" +099 "Adres deÄŸeri taşımı" +100 "Adres deÄŸeri alttaşımı" +101 "Ä°zin verilmeyen adres birleÅŸimi" +102 "Ä°zin verilmeyen adres: Dosyada yalnızca %lu satır var" +103 "Ä°zin verilmeyen adres: Dosya boÅŸ" +104 "%s komutu bir 0 adresine izin vermiyor" +105 "Görüntülenecek kısaltma yok" +106 "Kısaltmalar bir \"sözcük\" karakteri ile bitmelidir" +107 "Kısaltmalar sekme veya boÅŸluk içeremez" +108 "Kısaltmalar sonu dışında sözcük/sözcük olmayan karakterleri karıştıramaz" +109 "\"%s\" bir kısaltma deÄŸil" +110 "Vi komutu baÅŸarısız: EÅŸlemlenen düğmeler çıkarıldı" +111 "Düzenlenecek baÅŸka dosya yok" +112 "Öncesinde düzenlenecek baÅŸka dosya yok" +113 "Öncesinde geri sarılacak dosyalar yok" +114 "Görüntülenecek dosya yok" +115 "Öncesinde \"!\" ögesinin yerine geçecek bir komut yok" +116 "%% yerine geçecek bir dosya adı yok" +117 "# yerine geçecek bir dosya adı yok" +118 "Hata: execl: %s" +119 "Girdi/Çıktı hatası: %s" +120 "Dosya son tam yazımdan bu yana deÄŸiÅŸtirilmiÅŸ; yazın veya yok saymak için ! kullanın" +121 "Ev dizini konumu bulunamıyor" +122 "Yeni ÅŸimdiki dizin: %s" +123 "Görüntülenecek kesilmiÅŸ arabellek yok" +124 "%s komutu bir global veya v komutunun parçası olarak kullanılamaz" +128 "%s: kaynak alınmıyor: Ä°yesi siz veya kök deÄŸil" +129 "%s: kaynak alınmıyor: Ä°yesi siz deÄŸilsiniz" +130 "%s: kaynak alınmıyor: Ä°yesi dışında baÅŸka bir kullanıcı tarafından yazılabilir" +131 "Uç uca eklenecek bir satır yok" +132 "Girdi eÅŸlem girdisi yok" +133 "Komut eÅŸlem girdisi yok" +134 "%s yeniden eÅŸlemlenemeyebilir" +135 "\"%s\" ÅŸu anda eÅŸlemlenmemiÅŸ" +136 "Ä°m adları tek bir karakter olmalıdır" +137 "%s mevcut, yazılmamış; yok saymak için ! kullanın" +138 "Yeni exrc dosyası: %s" +139 "Hedef satırı taşıma erimi içinde" +140 "'open' komutu 'open' seçeneÄŸinin ayarlı olmasını gerektirir" +141 "'open' komutu henüz eklenmemiÅŸ" +142 "Bu dosyanın korunması olanaklı deÄŸil" +143 "Dosya korundu" +144 "%s: Çok fazla dosya adına geniÅŸletilmiÅŸ" +145 "Yalnızca sıradan dosyalar ve adlandırılmış veri yolları okunabilir" +146 "%s: Okuma kilidi kullanılabilir deÄŸildi" +147 "Okunuyor..." +148 "%s: %lu satır, %lu karakter" +149 "Görüntülenecek arkaplan ekranı yok" +150 "'script' komutu yalnızca vi kipinde kullanılabilir" +151 "Çalıştırılacak komut yok" +152 "'shiftwidth' seçeneÄŸi 0 olarak ayarlanmış" +153 "Sayım taşımı" +154 "Sayım alttaşımı" +155 "Düzenli ifade belirtilmiÅŸ; r bayrağı anlamsız" +156 "#, l ve p bayrakları vi kipinde c bayrağı ile birlikte kullanılamaz" +157 "EÅŸleÅŸme bulunamadı" +158 "Önceden bir etiket girilmemiÅŸ" +159 "Etiket yığınında %s sayısından az girdi; :display t[ags] kullanın" +160 "Etiket yığınında dönülecek bir %s dosyası yok; :display t[ags] kullanın" +161 "Sürdürmek için Enter'a basın:" +162 "%s: Etiket bulunamadı" +163 "%s: %s içinde hasar görmüş etiket" +164 "%s: Etiketin satır numarası dosya sonunu geçmiÅŸ" +165 "Etiket yığını boÅŸ" +166 "%s: Arama dizgisi bulunamadı" +167 "%d dosya daha düzenlenecek" +168 "%s arabelleÄŸi boÅŸ" +169 "DeÄŸiÅŸikliÄŸi onayla? [n]" +170 "Yarıda kesildi" +171 "Öncesinde çalıştırılacak arabellek yok" +172 "Öncesinde düzenli ifade yok" +173 "%s komutu bir dosyanın halihazırda okunmuÅŸ olmasını gerektirir" +174 "Kullanım: %s" +175 "'visual' komutu 'open' seçeneÄŸinin ayarlanmış olmasını gerektirir" +177 "BoÅŸ dosya" +178 "Öncesinde F, f, T veya t araması yok" +179 "%s bulunamadı" +180 "Düzenlenecek dosya yok" +181 "Ä°mleç bir sayıda deÄŸil" +182 "Ortaya çıkan sayı çok büyük" +183 "Ortaya çıkan sayı çok küçük" +184 "Bu satırda eÅŸleÅŸen karakter yok" +185 "EÅŸleÅŸen karakter bulunamadı" +186 "DeÄŸiÅŸtirilecek karakter yok" +187 "Geçilecek baÅŸka ekran yok" +188 "Arama dizgisinden, satır ofsetinden ve/veya 'z' komutundan sonraki karakterler" +189 "Öncesinde arama dizgisi yok" +190 "Arama baÅŸlanan konumda tamamlandı" +191 "Kısaltma geniÅŸleme sınırını aÅŸtı: Karakterler çıkarıldı" +192 "Ä°zin verilmeyen karakter; giriÅŸ için tırnak içine alın" +193 "Halihazırda eklemenin başında" +194 "Silinecek baÅŸka karakter yok" +195 "Hareket dosya sonunu geçti" +196 "Hareket satır sonunu geçti" +197 "Ä°mleç hareket ettirilmedi" +198 "Halihazırda dosyanın başında" +199 "Hareket dosyanın başını geçti" +200 "Halihazırda ilk sütunda" +201 "Arabellekler komuttan önce belirtilmeli" +202 "Halihazırda dosya sonunda" +203 "Halihazırda satır sonunda" +204 "%s bir vi komutu deÄŸil" +205 "Kullanım: %s" +206 "Silinecek karakter yok" +207 "Q komutu ex uçbirim arabirimini gerektirir" +208 "Yinelenecek komut yok" +209 "Dosya boÅŸ" +210 "%s bir hareket komutu olarak kullanılamaz" +211 "Halihazırda komut kipi içinde" +212 "Ä°mleç bir sözcükte deÄŸil" +214 "'windows' seçeneÄŸi deÄŸeri çok büyük, en çok %u olabilir" +215 "Ä°liÅŸtir" +216 "DeÄŸiÅŸiklik yap" +217 "Komut" +218 "Ekle" +219 "DeÄŸiÅŸtir" +220 "Hareket ekran sonunu geçti" +221 "Hareket ekran başını geçti" +222 "Ekran bölünebilmesi için %d satırdan daha geniÅŸ olmalıdır" +223 "Arkaplan ekranı yok" +224 "Arkaplanda %s dosyasını düzenleyen bir ekran yok" +225 "Açık olan tek ekranınızı arkaplana alamazsınız" +226 "Ekran yalnızca %d satıra küçültülebilir" +227 "Ekran küçülemez" +228 "Ekran büyüyemez" +230 "Bu ekran askıya alınamaz" +231 "Yarıda kesildi: EÅŸlemlenen düğmeler çıkarıldı" +232 "vi: Geçici arabellek salıverilmedi" +233 "Bu uçbirimde %s düğmesi yok" +234 "Yalnızca bir arabellek belirtilebilir" +235 "Sayı ÅŸundan daha büyük: %lu" +236 "Yarıda kesildi" +237 "Geçici dosya oluÅŸturulamıyor" +238 "Uyarı: %s sıradan bir dosya deÄŸil" +239 "%s halihazırda kilitlenmiÅŸ, oturum saltokunur" +240 "%s: Kaldır" +241 "%s: Kapat" +242 "%s: Kaldır" +243 "%s: Kaldır" +244 "Saltokunur dosya, yazılmadı; yok saymak için ! kullanın" +245 "Saltokunur dosya, yazılmadı" +246 "%s mevcut, yazılmadı; yok saymak için ! kullanın" +247 "%s mevcut, yazılmadı" +248 "Kısmi dosya, yazılmadı; yok saymak için ! kullanın" +249 "Kısmi dosya, yazılmadı" +250 "%s: Dosya bu kopyadan daha önce deÄŸiÅŸtirilmiÅŸ; yok saymak için ! kullanın" +251 "%s: Dosya bu kopyadan daha önce deÄŸiÅŸtirilmiÅŸ" +252 "%s: Yazım koruması kullanılabilir deÄŸildi" +253 "Yazılıyor..." +254 "%s: UYARI: DOSYA KIRPILMIÅž" +255 "Halihazırda bu grubun ilk etiketinde" +256 "%s: Yeni dosya: %lu satır, %lu karakter" +257 "%s: %lu satır, %lu karakter" +258 "%s çok fazla dosya adına geniÅŸletilmiÅŸ" +259 "%s: Sıradan bir dosya deÄŸil" +260 "%s: Ä°yesi siz deÄŸilsiniz" +261 "%s: Ä°yesi dışında baÅŸka bir kullanıcı tarafından da eriÅŸilebilir" +262 "Dosya son tam yazımdan bu yana deÄŸiÅŸtirilmiÅŸ; yazın veya yok saymak için ! kullanın" +263 "Dosya son tam yazımdan bu yana deÄŸiÅŸtirilmiÅŸ; yazın veya yok saymak için :edit! kullanın" +264 "Dosya son tam yazımdan bu yana deÄŸiÅŸtirilmiÅŸ; yazın veya yok saymak için ! kullanın" +265 "Dosya geçici; çıkarsanız deÄŸiÅŸiklikler atılacaktır" +266 "Dosya saltokunur, deÄŸiÅŸiklikler kendiliÄŸinden yazılmaz" +267 "Günlük yeniden baÅŸlatıldı" +268 "Onayla? [ynq]" +269 "Sürdürmek için herhangi bir düğmeye basın: " +270 "Sürdürmek için herhangi bir düğmeye basın [ex komutu girmek için :]: " +271 "Sürdürmek için herhangi bir düğmeye basın [çıkış için q]: " +272 "Bu biçim %s ex uçbirim arabirimini gerektirir" +273 "ex girdisi kipine giriliyor" +274 "Komut baÅŸarısız, henüz bir dosya okunmadı." +275 " sürdür?" +276 "Beklenmedik karakter olayı" +277 "Beklenmedik dosya sonu olayı" +278 "Sorgu eÅŸleÅŸmesi bulunamadı" +279 "Beklenmedik yarıda kesme olayı" +281 "Beklenmedik yeniden boyama olayı" +282 "Halihazırda bu grubun son etiketinde" +283 "%s komutu ex uçbirim arabirimini gerektirir" +284 "Bu biçim %s 'secure edit' seçeneÄŸi ayarlandığında desteklenmez" +285 "Beklenmedik dizi olayı" +286 "Beklenmedik zaman aşımı olayı" +288 "Bölünebilmesi için ekran %d sütundan daha geniÅŸ olmalıdır" +289 "Kabuk geniÅŸletmeleri 'secure edit' seçeneÄŸi ayarlandığında desteklenmez" +290 "%s komutu 'secure edit' seçeneÄŸi ayarlandığında desteklenmez" +291 "set: %s seçeneÄŸi kapatılamaz" +292 "Ekran çok küçük." +293 "eklendi" +294 "deÄŸiÅŸtirildi" +295 "silindi" +296 "uç uca eklendi" +297 "taşındı" +298 "kaydırıldı" +299 "kopyalandı" +300 "satır" +301 "satır" +303 "Dosya son yazımdan bu yana deÄŸiÅŸtirilmiÅŸ." +304 "Kabuk geniÅŸletmesi baÅŸarısız" +305 "Bir '%s' düzenleme seçeneÄŸi belirtilmedi" +307 "Çalıştırılacak ex komutu yok" +308 "Bir komut çalıştırmak için , çıkmak için :q girin" +309 "Yardım için \"cscope help\" kullanın" +310 "Çalışan bir cscope baÄŸlantısı yok" +311 "%s: Bilinmeyen arama türü: Åžunlardan bir tanesini kullanın: %s" +312 "%d: Böyle bir cscope oturumu yok" +313 "set: %s seçeneÄŸi hiçbir zaman açılamaz" +314 "set: %s seçeneÄŸi hiçbir zaman 0 olarak ayarlanamaz" +315 "%s: Ä°liÅŸtirildi: %lu satır, %lu karakter" +316 "Beklenmedik yeniden boyutlandırma olayı" +317 "Düzenlenecek %d dosya var" +319 "%d ekran arkaplana alındı; onları listelemek için :display kullanın" +320 "Bilinmeyen imleç konumu" +321 "Dosya kodlama dönüştürmesi desteklenmiyor" +322 "Girdi kodlama dönüştürmesi desteklenmiyor" +323 "Geçersiz girdi. Kırpıldı." +324 "%d numaralı satırda dönüştürme hatası" diff --git a/catalog/tr_TR.UTF-8.owner b/catalog/tr_TR.UTF-8.owner new file mode 100644 index 000000000000..2739e5bbfd61 --- /dev/null +++ b/catalog/tr_TR.UTF-8.owner @@ -0,0 +1 @@ +Emir SARI diff --git a/cl/README.signal b/cl/README.signal index 18b3d1451b00..72a13b59bec1 100644 --- a/cl/README.signal +++ b/cl/README.signal @@ -1,5 +1,3 @@ -# $Id: README.signal,v 10.1 1995/06/23 10:28:17 bostic Exp $ - There are six (normally) asynchronous actions about which vi cares: SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGTSTP and SIGWINCH. diff --git a/cl/cl.h b/cl/cl.h index cca0acb8eba7..894e5ede7fa9 100644 --- a/cl/cl.h +++ b/cl/cl.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: cl.h,v 10.34 2011/08/15 20:07:32 zy Exp $ */ #ifdef USE_WIDECHAR diff --git a/cl/cl_funcs.c b/cl/cl_funcs.c index 4c15458456ad..32ca823c04cc 100644 --- a/cl/cl_funcs.c +++ b/cl/cl_funcs.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: cl_funcs.c,v 10.74 2012/10/11 10:30:16 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/cl/cl_main.c b/cl/cl_main.c index 42c3c82b84f1..002f4f2295c2 100644 --- a/cl/cl_main.c +++ b/cl/cl_main.c @@ -9,14 +9,11 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: cl_main.c,v 10.56 2015/04/05 06:20:53 zy Exp $"; -#endif /* not lint */ - #include #include #include +#include #include #include #include @@ -38,11 +35,10 @@ sigset_t __sigblockset; /* GLOBAL: Blocked signals. */ static void cl_func_std(GS *); static CL_PRIVATE *cl_init(GS *); -static GS *gs_init(char *); -static void perr(char *, char *); +static GS *gs_init(void); static int setsig(int, struct sigaction *, void (*)(int)); static void sig_end(GS *); -static void term_init(char *, char *); +static void term_init(char *); /* * main -- @@ -63,7 +59,7 @@ main(int argc, char *argv[]) abort(); /* Create and initialize the global structure. */ - __global_list = gp = gs_init(argv[0]); + __global_list = gp = gs_init(); /* * Strip out any arguments that vi isn't going to understand. There's @@ -93,12 +89,12 @@ main(int argc, char *argv[]) */ if ((ttype = getenv("TERM")) == NULL) ttype = "ansi"; - term_init(gp->progname, ttype); + term_init(ttype); /* Add the terminal type to the global structure. */ if ((OG_D_STR(gp, GO_TERM) = OG_STR(gp, GO_TERM) = strdup(ttype)) == NULL) - perr(gp->progname, NULL); + err(1, NULL); /* Figure out how big the screen is. */ if (cl_ssize(NULL, 0, &rows, &cols, NULL)) @@ -147,8 +143,7 @@ main(int argc, char *argv[]) /* Free the global and CL private areas. */ #if defined(DEBUG) || defined(PURIFY) - if (clp->oname != NULL) - free(clp->oname); + free(clp->oname); free(clp); free(OG_STR(gp, GO_TERM)); free(gp); @@ -162,21 +157,14 @@ main(int argc, char *argv[]) * Create and partially initialize the GS structure. */ static GS * -gs_init(char *name) +gs_init(void) { GS *gp; - char *p; - /* Figure out what our name is. */ - if ((p = strrchr(name, '/')) != NULL) - name = p + 1; - - /* Allocate the global structure. */ - CALLOC_NOMSG(NULL, gp, GS *, 1, sizeof(GS)); + gp = calloc(1, sizeof(GS)); if (gp == NULL) - perr(name, NULL); + err(1, NULL); - gp->progname = name; return (gp); } @@ -190,10 +178,9 @@ cl_init(GS *gp) CL_PRIVATE *clp; int fd; - /* Allocate the CL private structure. */ - CALLOC_NOMSG(NULL, clp, CL_PRIVATE *, 1, sizeof(CL_PRIVATE)); + clp = calloc(1, sizeof(CL_PRIVATE)); if (clp == NULL) - perr(gp->progname, NULL); + err(1, NULL); gp->cl_private = clp; /* @@ -216,7 +203,7 @@ cl_init(GS *gp) goto tcfail; } else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) { if (tcgetattr(fd, &clp->orig) == -1) { -tcfail: perr(gp->progname, "tcgetattr"); +tcfail: err(1, "tcgetattr"); exit (1); } (void)close(fd); @@ -233,7 +220,7 @@ tcfail: perr(gp->progname, "tcgetattr"); * Initialize terminal information. */ static void -term_init(char *name, char *ttype) +term_init(char *ttype) { int err; @@ -241,13 +228,9 @@ term_init(char *name, char *ttype) setupterm(ttype, STDOUT_FILENO, &err); switch (err) { case -1: - (void)fprintf(stderr, - "%s: No terminal database found\n", name); - exit (1); + errx(1, "No terminal database found"); case 0: - (void)fprintf(stderr, - "%s: %s: unknown terminal type\n", name, ttype); - exit (1); + errx(1, "%s: unknown terminal type", ttype); } } @@ -315,7 +298,7 @@ sig_init(GS *gp, SCR *sp) setsig(SIGWINCH, &clp->oact[INDX_WINCH], h_winch) #endif ) { - perr(gp->progname, NULL); + err(1, NULL); return (1); } } else @@ -406,17 +389,3 @@ cl_func_std(GS *gp) gp->scr_suspend = cl_suspend; gp->scr_usage = cl_usage; } - -/* - * perr -- - * Print system error. - */ -static void -perr(char *name, char *msg) -{ - (void)fprintf(stderr, "%s:", name); - if (msg != NULL) - (void)fprintf(stderr, "%s:", msg); - (void)fprintf(stderr, "%s\n", strerror(errno)); - exit(1); -} diff --git a/cl/cl_read.c b/cl/cl_read.c index 3d9064c56002..f5f18fd616f1 100644 --- a/cl/cl_read.c +++ b/cl/cl_read.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: cl_read.c,v 10.30 2012/07/12 18:28:58 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/cl/cl_screen.c b/cl/cl_screen.c index 16c87725487d..91864eb4999f 100644 --- a/cl/cl_screen.c +++ b/cl/cl_screen.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: cl_screen.c,v 10.58 2015/04/08 02:12:11 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -450,14 +446,11 @@ cl_ex_init(SCR *sp) /* Enter_standout_mode and exit_standout_mode are paired. */ if (clp->smso == NULL || clp->rmso == NULL) { - if (clp->smso != NULL) { - free(clp->smso); - clp->smso = NULL; - } - if (clp->rmso != NULL) { - free(clp->rmso); - clp->rmso = NULL; - } + free(clp->smso); + clp->smso = NULL; + + free(clp->rmso); + clp->rmso = NULL; } /* @@ -526,7 +519,7 @@ cl_getcap(SCR *sp, char *name, char **elementp) if ((t = tigetstr(name)) != NULL && t != (char *)-1 && (len = strlen(t)) != 0) { - MALLOC_RET(sp, *elementp, char *, len + 1); + MALLOC_RET(sp, *elementp, len + 1); memmove(*elementp, t, len + 1); } return (0); @@ -539,32 +532,25 @@ cl_getcap(SCR *sp, char *name, char **elementp) static void cl_freecap(CL_PRIVATE *clp) { - if (clp->el != NULL) { - free(clp->el); - clp->el = NULL; - } - if (clp->cup != NULL) { - free(clp->cup); - clp->cup = NULL; - } - if (clp->cuu1 != NULL) { - free(clp->cuu1); - clp->cuu1 = NULL; - } - if (clp->rmso != NULL) { - free(clp->rmso); - clp->rmso = NULL; - } - if (clp->smso != NULL) { - free(clp->smso); - clp->smso = NULL; - } + free(clp->el); + clp->el = NULL; + + free(clp->cup); + clp->cup = NULL; + + free(clp->cuu1); + clp->cuu1 = NULL; + + free(clp->rmso); + clp->rmso = NULL; + + free(clp->smso); + clp->smso = NULL; + /* Required by libcursesw :) */ - if (clp->cw.bp1.c != NULL) { - free(clp->cw.bp1.c); - clp->cw.bp1.c = NULL; - clp->cw.blen1 = 0; - } + free(clp->cw.bp1.c); + clp->cw.bp1.c = NULL; + clp->cw.blen1 = 0; } /* diff --git a/cl/cl_term.c b/cl/cl_term.c index d4b1efc8fe84..601460585530 100644 --- a/cl/cl_term.c +++ b/cl/cl_term.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: cl_term.c,v 10.35 2015/04/08 02:12:11 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -35,6 +31,7 @@ static const char sccsid[] = "$Id: cl_term.c,v 10.35 2015/04/08 02:12:11 zy Exp #include "cl.h" static int cl_pfmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t); +static size_t atoz_or(const char *, size_t); /* * XXX @@ -453,9 +450,9 @@ noterm: if (row == 0) * dot-files. */ if ((p = getenv("LINES")) != NULL) - row = strtol(p, NULL, 10); + row = atoz_or(p, row); if ((p = getenv("COLUMNS")) != NULL) - col = strtol(p, NULL, 10); + col = atoz_or(p, col); if (rowp != NULL) *rowp = row; @@ -464,6 +461,22 @@ noterm: if (row == 0) return (0); } +/* + * atoz_or -- + * Parse non-zero positive decimal with a fallback. + */ +static size_t +atoz_or(const char *s, size_t y) +{ + char *ep; + long x = strtol(s, &ep, 10); + + if (*ep == '\0' && (0 < x && x < INT_MAX)) + return (size_t)x; + else + return y; +} + /* * cl_putchar -- * Function version of putchar, for tputs. diff --git a/cl/extern.h b/cl/extern.h deleted file mode 100644 index 7b01ccd3f8cf..000000000000 --- a/cl/extern.h +++ /dev/null @@ -1,31 +0,0 @@ -int cl_waddstr(SCR *, const CHAR_T *, size_t); -int cl_addstr(SCR *, const char *, size_t); -int cl_attr(SCR *, scr_attr_t, int); -int cl_baud(SCR *, u_long *); -int cl_bell(SCR *); -int cl_clrtoeol(SCR *); -int cl_cursor(SCR *, size_t *, size_t *); -int cl_deleteln(SCR *); -int cl_discard(SCR *, SCR **); -int cl_ex_adjust(SCR *, exadj_t); -int cl_insertln(SCR *); -int cl_keyval(SCR *, scr_keyval_t, CHAR_T *, int *); -int cl_move(SCR *, size_t, size_t); -int cl_refresh(SCR *, int); -int cl_rename(SCR *, char *, int); -void cl_setname(GS *, char *); -int cl_split(SCR *, SCR *); -int cl_suspend(SCR *, int *); -void cl_usage(void); -int sig_init(GS *, SCR *); -int cl_event(SCR *, EVENT *, u_int32_t, int); -int cl_screen(SCR *, u_int32_t); -int cl_quit(GS *); -int cl_getcap(SCR *, char *, char **); -int cl_term_init(SCR *); -int cl_term_end(GS *); -int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t); -int cl_optchange(SCR *, int, char *, u_long *); -int cl_omesg(SCR *, CL_PRIVATE *, int); -int cl_ssize(SCR *, int, size_t *, size_t *, int *); -int cl_putchar(int); diff --git a/common/args.h b/common/args.h index b23699c250e3..3f9b43a272ac 100644 --- a/common/args.h +++ b/common/args.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: args.h,v 10.2 1996/03/06 19:50:07 bostic Exp $ */ /* diff --git a/common/common.h b/common/common.h index c64adb51d6b4..ad559a5a2267 100644 --- a/common/common.h +++ b/common/common.h @@ -5,17 +5,10 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: common.h,v 10.22 2012/04/13 05:21:50 zy Exp $ */ -/* - * Pseudo-local includes. These are files that are unlikely to exist - * on most machines to which we're porting vi, and we want to include - * them in a very specific order, regardless. - */ -#include -#include +#include "/usr/include/db.h" /* Only include db1. */ +#include /* May refer to the bundled regex. */ /* * Forward structure declarations. Not pretty, but the include files diff --git a/common/conv.c b/common/conv.c index aaa7af37e548..2e675a6d3f77 100644 --- a/common/conv.c +++ b/common/conv.c @@ -11,10 +11,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: conv.c,v 2.40 2014/02/27 16:25:29 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -118,7 +114,7 @@ default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw, size_t left = len; int error = 1; - BZERO(&mbs, 1); + memset(&mbs, 0, sizeof(mbs)); BINC_RETW(NULL, *tostr, *blen, nlen); #ifdef USE_ICONV @@ -245,7 +241,7 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw, #endif - BZERO(&mbs, 1); + memset(&mbs, 0, sizeof(mbs)); BINC_RETC(NULL, *tostr, *blen, nlen); dst = *tostr; buflen = *blen; @@ -323,7 +319,7 @@ conv_init(SCR *orig, SCR *sp) if (orig == NULL) setlocale(LC_ALL, ""); if (orig != NULL) - BCOPY(&orig->conv, &sp->conv, 1); + memmove(&sp->conv, &orig->conv, sizeof(CONV)); #ifdef USE_WIDECHAR else { char *ctype = setlocale(LC_CTYPE, NULL); @@ -464,7 +460,6 @@ conv_end(SCR *sp) for (i = 0; i <= IC_IE_TO_UTF16; ++i) if (sp->conv.id[i] != (iconv_t)-1) iconv_close(sp->conv.id[i]); - if (sp->cw.bp1.c != NULL) - free(sp->cw.bp1.c); + free(sp->cw.bp1.c); #endif } diff --git a/common/conv.h b/common/conv.h index b17c3bb24ace..ee3efb5a8308 100644 --- a/common/conv.h +++ b/common/conv.h @@ -7,8 +7,6 @@ * Zhihao Yuan. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: conv.h,v 2.32 2013/03/11 01:20:53 zy Exp $ */ #ifdef USE_ICONV diff --git a/common/cut.c b/common/cut.c index 810aef6ac89c..7d74f764a6d9 100644 --- a/common/cut.c +++ b/common/cut.c @@ -9,12 +9,9 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: cut.c,v 10.12 2012/02/11 15:52:33 zy Exp $"; -#endif /* not lint */ - #include #include +#include #include #include @@ -64,12 +61,7 @@ static void cb_rotate(SCR *); * PUBLIC: int cut(SCR *, CHAR_T *, MARK *, MARK *, int); */ int -cut( - SCR *sp, - CHAR_T *namep, - MARK *fm, - MARK *tm, - int flags) +cut(SCR *sp, CHAR_T *namep, MARK *fm, MARK *tm, int flags) { CB *cbp; CHAR_T name = '\0'; @@ -126,7 +118,7 @@ namecb: CBNAME(sp, cbp, name); * Otherwise, if it's not an append, free its current contents. */ if (cbp == NULL) { - CALLOC_RET(sp, cbp, CB *, 1, sizeof(CB)); + CALLOC_RET(sp, cbp, 1, sizeof(CB)); cbp->name = name; TAILQ_INIT(cbp->textq); SLIST_INSERT_HEAD(sp->gp->cutq, cbp, q); @@ -225,12 +217,7 @@ cb_rotate(SCR *sp) * PUBLIC: int cut_line(SCR *, recno_t, size_t, size_t, CB *); */ int -cut_line( - SCR *sp, - recno_t lno, - size_t fcno, - size_t clen, - CB *cbp) +cut_line(SCR *sp, recno_t lno, size_t fcno, size_t clen, CB *cbp) { TEXT *tp; size_t len; @@ -294,20 +281,16 @@ cut_close(GS *gp) * PUBLIC: TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t); */ TEXT * -text_init( - SCR *sp, - const CHAR_T *p, - size_t len, - size_t total_len) +text_init(SCR *sp, const CHAR_T *p, size_t len, size_t total_len) { TEXT *tp; - CALLOC(sp, tp, TEXT *, 1, sizeof(TEXT)); + CALLOC(sp, tp, 1, sizeof(TEXT)); if (tp == NULL) return (NULL); /* ANSI C doesn't define a call to malloc(3) for 0 bytes. */ if ((tp->lb_len = total_len * sizeof(CHAR_T)) != 0) { - MALLOC(sp, tp->lb, CHAR_T *, tp->lb_len); + MALLOC(sp, tp->lb, tp->lb_len); if (tp->lb == NULL) { free(tp); return (NULL); @@ -345,7 +328,6 @@ text_lfree(TEXTH *headp) void text_free(TEXT *tp) { - if (tp->lb != NULL) - free(tp->lb); + free(tp->lb); free(tp); } diff --git a/common/cut.h b/common/cut.h index 30e9350dbb75..d220cd8cc69c 100644 --- a/common/cut.h +++ b/common/cut.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: cut.h,v 10.10 2012/02/11 15:52:33 zy Exp $ */ typedef struct _texth TEXTH; /* TEXT list head structure. */ diff --git a/common/delete.c b/common/delete.c index b9bd0388946f..f52132340f06 100644 --- a/common/delete.c +++ b/common/delete.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: delete.c,v 10.18 2012/02/11 15:52:33 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -33,11 +29,7 @@ static const char sccsid[] = "$Id: delete.c,v 10.18 2012/02/11 15:52:33 zy Exp $ * PUBLIC: int del(SCR *, MARK *, MARK *, int); */ int -del( - SCR *sp, - MARK *fm, - MARK *tm, - int lmode) +del(SCR *sp, MARK *fm, MARK *tm, int lmode) { recno_t lno; size_t blen, len, nlen, tlen; @@ -94,14 +86,16 @@ del( if (tm->lno == fm->lno) { if (db_get(sp, fm->lno, DBG_FATAL, &p, &len)) return (1); - GET_SPACE_RETW(sp, bp, blen, len); - if (fm->cno != 0) - MEMCPY(bp, p, fm->cno); - MEMCPY(bp + fm->cno, p + (tm->cno + 1), - len - (tm->cno + 1)); - if (db_set(sp, fm->lno, - bp, len - ((tm->cno - fm->cno) + 1))) - goto err; + if (len != 0) { + GET_SPACE_RETW(sp, bp, blen, len); + if (fm->cno != 0) + MEMCPY(bp, p, fm->cno); + MEMCPY(bp + fm->cno, p + (tm->cno + 1), + len - (tm->cno + 1)); + if (db_set(sp, fm->lno, + bp, len - ((tm->cno - fm->cno) + 1))) + goto err; + } goto done; } diff --git a/common/encoding.c b/common/encoding.c index 7bdcf7069238..a1ff1c102135 100644 --- a/common/encoding.c +++ b/common/encoding.c @@ -5,10 +5,6 @@ * See the LICENSE file for redistribution information. */ -#ifndef lint -static const char sccsid[] = "$Id: encoding.c,v 1.4 2011/12/13 19:40:52 zy Exp $"; -#endif /* not lint */ - #include int looks_utf8(const char *, size_t); @@ -96,7 +92,7 @@ looks_utf8(const char *ibuf, size_t nbytes) if (i >= nbytes) goto done; - if (buf[i] & 0x40) /* 10xxxxxx */ + if ((buf[i] & 0xc0) != 0x80) /* 10xxxxxx */ return -1; } diff --git a/common/exf.c b/common/exf.c index 1fcf7f6da498..ccfa66ef4089 100644 --- a/common/exf.c +++ b/common/exf.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: exf.c,v 10.64 2015/04/05 15:21:55 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -59,9 +55,7 @@ static int file_spath(SCR *, FREF *, struct stat *, int *); * PUBLIC: FREF *file_add(SCR *, char *); */ FREF * -file_add( - SCR *sp, - char *name) +file_add(SCR *sp, char *name) { GS *gp; FREF *frp, *tfrp; @@ -80,8 +74,7 @@ file_add( TAILQ_FOREACH_SAFE(frp, gp->frefq, q, tfrp) { if (frp->name == NULL) { TAILQ_REMOVE(gp->frefq, frp, q); - if (frp->name != NULL) - free(frp->name); + free(frp->name); free(frp); continue; } @@ -90,7 +83,7 @@ file_add( } /* Allocate and initialize the FREF structure. */ - CALLOC(sp, frp, FREF *, 1, sizeof(FREF)); + CALLOC(sp, frp, 1, sizeof(FREF)); if (frp == NULL) return (NULL); @@ -121,11 +114,7 @@ file_add( * PUBLIC: int file_init(SCR *, FREF *, char *, int); */ int -file_init( - SCR *sp, - FREF *frp, - char *rcv_name, - int flags) +file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) { EXF *ep; RECNOINFO oinfo = { 0 }; @@ -160,7 +149,7 @@ file_init( * Default recover mail file fd to -1. * Set initial EXF flag bits. */ - CALLOC_RET(sp, ep, EXF *, 1, sizeof(EXF)); + CALLOC_RET(sp, ep, 1, sizeof(EXF)); ep->c_lno = ep->c_nlines = OOBLNO; ep->rcv_fd = -1; F_SET(ep, F_FIRSTMODIFY); @@ -356,9 +345,9 @@ file_init( * vi, unless the -R command-line option was specified or the program * was executed as "view". (Well, to be truthful, if the letter 'w' * occurred anywhere in the program name, but let's not get into that.) - * So, the persistant readonly state has to be stored in the screen + * So, the persistent readonly state has to be stored in the screen * structure, and the edit option value toggles with the contents of - * the edit buffer. If the persistant readonly flag is set, set the + * the edit buffer. If the persistent readonly flag is set, set the * readonly edit option. * * Otherwise, try and figure out if a file is readonly. This is a @@ -418,10 +407,8 @@ file_init( return (0); -err: if (frp->name != NULL) { - free(frp->name); - frp->name = NULL; - } +err: free(frp->name); + frp->name = NULL; if (frp->tname != NULL) { (void)unlink(frp->tname); free(frp->tname); @@ -430,10 +417,9 @@ err: if (frp->name != NULL) { oerr: if (F_ISSET(ep, F_RCV_ON)) (void)unlink(ep->rcv_path); - if (ep->rcv_path != NULL) { - free(ep->rcv_path); - ep->rcv_path = NULL; - } + free(ep->rcv_path); + ep->rcv_path = NULL; + if (ep->db != NULL) (void)ep->db->close(ep->db); free(ep); @@ -448,11 +434,7 @@ oerr: if (F_ISSET(ep, F_RCV_ON)) * try and open. */ static int -file_spath( - SCR *sp, - FREF *frp, - struct stat *sbp, - int *existsp) +file_spath(SCR *sp, FREF *frp, struct stat *sbp, int *existsp) { int savech; size_t len; @@ -564,7 +546,7 @@ file_cinit(SCR *sp) } CHAR2INT(sp, gp->c_option, strlen(gp->c_option) + 1, wp, wlen); - if (ex_run_str(sp, "-c option", wp, wlen - 1, 1, 1)) + if (ex_run_str(sp, "-c option", wp, wlen - 1, 1, 0)) return; gp->c_option = NULL; } else if (F_ISSET(sp, SC_EX)) { @@ -632,10 +614,7 @@ file_cinit(SCR *sp) * PUBLIC: int file_end(SCR *, EXF *, int); */ int -file_end( - SCR *sp, - EXF *ep, - int force) +file_end(SCR *sp, EXF *ep, int force) { FREF *frp; @@ -681,8 +660,7 @@ file_end( frp->tname = NULL; if (F_ISSET(frp, FR_TMPFILE)) { TAILQ_REMOVE(sp->gp->frefq, frp, q); - if (frp->name != NULL) - free(frp->name); + free(frp->name); free(frp); } sp->frp = NULL; @@ -724,10 +702,8 @@ file_end( } if (ep->rcv_fd != -1) (void)close(ep->rcv_fd); - if (ep->rcv_path != NULL) - free(ep->rcv_path); - if (ep->rcv_mpath != NULL) - free(ep->rcv_mpath); + free(ep->rcv_path); + free(ep->rcv_mpath); if (ep->c_blen > 0) free(ep->c_lp); @@ -744,12 +720,7 @@ file_end( * PUBLIC: int file_write(SCR *, MARK *, MARK *, char *, int); */ int -file_write( - SCR *sp, - MARK *fm, - MARK *tm, - char *name, - int flags) +file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags) { enum { NEWFILE, OLDFILE } mtype; struct stat sb; @@ -1016,10 +987,7 @@ file_write( * recreate the file. So, let's not risk it. */ static int -file_backup( - SCR *sp, - char *name, - char *bname) +file_backup(SCR *sp, char *name, char *bname) { struct dirent *dp; struct stat sb; @@ -1188,6 +1156,7 @@ file_backup( estr = wfname; goto err; } + free(d); if (bp != NULL) FREE_SPACE(sp, bp, blen); return (0); @@ -1201,8 +1170,7 @@ err: if (rfd != -1) } if (estr) msgq_str(sp, M_SYSERR, estr, "%s"); - if (d != NULL) - free(d); + free(d); if (bp != NULL) FREE_SPACE(sp, bp, blen); return (1); @@ -1306,10 +1274,7 @@ file_comment(SCR *sp) * PUBLIC: int file_m1(SCR *, int, int); */ int -file_m1( - SCR *sp, - int force, - int flags) +file_m1(SCR *sp, int force, int flags) { EXF *ep; @@ -1347,9 +1312,7 @@ file_m1( * PUBLIC: int file_m2(SCR *, int); */ int -file_m2( - SCR *sp, - int force) +file_m2(SCR *sp, int force) { EXF *ep; @@ -1379,9 +1342,7 @@ file_m2( * PUBLIC: int file_m3(SCR *, int); */ int -file_m3( - SCR *sp, - int force) +file_m3(SCR *sp, int force) { EXF *ep; @@ -1415,9 +1376,7 @@ file_m3( * PUBLIC: int file_aw(SCR *, int); */ int -file_aw( - SCR *sp, - int flags) +file_aw(SCR *sp, int flags) { if (!F_ISSET(sp->ep, F_MODIFIED)) return (0); @@ -1476,12 +1435,9 @@ file_aw( * PUBLIC: void set_alt_name(SCR *, char *); */ void -set_alt_name( - SCR *sp, - char *name) +set_alt_name(SCR *sp, char *name) { - if (sp->alt_name != NULL) - free(sp->alt_name); + free(sp->alt_name); if (name == NULL) sp->alt_name = NULL; else if ((sp->alt_name = strdup(name)) == NULL) @@ -1495,11 +1451,7 @@ set_alt_name( * PUBLIC: lockr_t file_lock(SCR *, char *, int, int); */ lockr_t -file_lock( - SCR *sp, - char *name, - int fd, - int iswrite) +file_lock(SCR *sp, char *name, int fd, int iswrite) { if (!O_ISSET(sp, O_LOCKFILES)) return (LOCK_SUCCESS); diff --git a/common/exf.h b/common/exf.h index 8f70d51dbb61..e6f8e31f0f7a 100644 --- a/common/exf.h +++ b/common/exf.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: exf.h,v 10.10 2012/07/06 16:03:37 zy Exp $ */ /* Undo direction. */ /* diff --git a/common/extern.h b/common/extern.h deleted file mode 100644 index f8acf8eacd83..000000000000 --- a/common/extern.h +++ /dev/null @@ -1,132 +0,0 @@ -char * codeset(void); -void conv_init(SCR *, SCR *); -int conv_enc(SCR *, int, char *); -void conv_end(SCR *); -int cut(SCR *, CHAR_T *, MARK *, MARK *, int); -int cut_line(SCR *, recno_t, size_t, size_t, CB *); -void cut_close(GS *); -TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t); -void text_lfree(TEXTH *); -void text_free(TEXT *); -int del(SCR *, MARK *, MARK *, int); -int looks_utf8(const char *, size_t); -int looks_utf16(const char *, size_t); -int decode_utf8(const char *); -int decode_utf16(const char *, int); -FREF *file_add(SCR *, char *); -int file_init(SCR *, FREF *, char *, int); -int file_end(SCR *, EXF *, int); -int file_write(SCR *, MARK *, MARK *, char *, int); -int file_m1(SCR *, int, int); -int file_m2(SCR *, int); -int file_m3(SCR *, int); -int file_aw(SCR *, int); -void set_alt_name(SCR *, char *); -lockr_t file_lock(SCR *, char *, int, int); -int v_key_init(SCR *); -void v_key_ilookup(SCR *); -size_t v_key_len(SCR *, ARG_CHAR_T); -char *v_key_name(SCR *, ARG_CHAR_T); -e_key_t v_key_val(SCR *, ARG_CHAR_T); -int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int); -int v_event_get(SCR *, EVENT *, int, u_int32_t); -void v_event_err(SCR *, EVENT *); -int v_event_flush(SCR *, u_int); -int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *); -int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *); -int db_delete(SCR *, recno_t); -int db_append(SCR *, int, recno_t, CHAR_T *, size_t); -int db_insert(SCR *, recno_t, CHAR_T *, size_t); -int db_set(SCR *, recno_t, CHAR_T *, size_t); -int db_exist(SCR *, recno_t); -int db_last(SCR *, recno_t *); -int db_rget(SCR *, recno_t, char **, size_t *); -int db_rset(SCR *, recno_t, char *, size_t); -void db_err(SCR *, recno_t); -int log_init(SCR *, EXF *); -int log_end(SCR *, EXF *); -int log_cursor(SCR *); -int log_line(SCR *, recno_t, u_int); -int log_mark(SCR *, LMARK *); -int log_backward(SCR *, MARK *); -int log_setline(SCR *); -int log_forward(SCR *, MARK *); -int editor(GS *, int, char *[]); -void v_end(GS *); -int mark_init(SCR *, EXF *); -int mark_end(SCR *, EXF *); -int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t); -int mark_set(SCR *, ARG_CHAR_T, MARK *, int); -int mark_insdel(SCR *, lnop_t, recno_t); -void msgq(SCR *, mtype_t, const char *, ...); -void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *); -void msgq_str(SCR *, mtype_t, const char *, const char *); -void mod_rpt(SCR *); -void msgq_status(SCR *, recno_t, u_int); -int msg_open(SCR *, char *); -void msg_close(GS *); -const char *msg_cmsg(SCR *, cmsg_t, size_t *); -const char *msg_cat(SCR *, const char *, size_t *); -char *msg_print(SCR *, const char *, int *); -int opts_init(SCR *, int *); -int opts_set(SCR *, ARGS *[], char *); -int o_set(SCR *, int, u_int, char *, u_long); -int opts_empty(SCR *, int, int); -void opts_dump(SCR *, enum optdisp); -int opts_save(SCR *, FILE *); -OPTLIST const *opts_search(CHAR_T *); -void opts_nomatch(SCR *, CHAR_T *); -int opts_copy(SCR *, SCR *); -void opts_free(SCR *); -int f_altwerase(SCR *, OPTION *, char *, u_long *); -int f_columns(SCR *, OPTION *, char *, u_long *); -int f_lines(SCR *, OPTION *, char *, u_long *); -int f_lisp(SCR *, OPTION *, char *, u_long *); -int f_msgcat(SCR *, OPTION *, char *, u_long *); -int f_print(SCR *, OPTION *, char *, u_long *); -int f_readonly(SCR *, OPTION *, char *, u_long *); -int f_recompile(SCR *, OPTION *, char *, u_long *); -int f_reformat(SCR *, OPTION *, char *, u_long *); -int f_ttywerase(SCR *, OPTION *, char *, u_long *); -int f_w300(SCR *, OPTION *, char *, u_long *); -int f_w1200(SCR *, OPTION *, char *, u_long *); -int f_w9600(SCR *, OPTION *, char *, u_long *); -int f_window(SCR *, OPTION *, char *, u_long *); -int f_encoding(SCR *, OPTION *, char *, u_long *); -int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int); -int rcv_tmp(SCR *, EXF *, char *); -int rcv_init(SCR *); -int rcv_sync(SCR *, u_int); -int rcv_list(SCR *); -int rcv_read(SCR *, FREF *); -int screen_init(GS *, SCR *, SCR **); -int screen_end(SCR *); -SCR *screen_next(SCR *); -int f_search(SCR *, - MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); -int b_search(SCR *, - MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); -void search_busy(SCR *, busy_t); -int seq_set(SCR *, CHAR_T *, - size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int); -int seq_delete(SCR *, CHAR_T *, size_t, seq_t); -int seq_free(SEQ *); -SEQ *seq_find - (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *); -void seq_close(GS *); -int seq_dump(SCR *, seq_t, int); -int seq_save(SCR *, FILE *, char *, seq_t); -int e_memcmp(CHAR_T *, EVENT *, size_t); -void *binc(SCR *, void *, size_t *, size_t); -int nonblank(SCR *, recno_t, size_t *); -char *tail(char *); -char *join(char *, char *); -char *expanduser(char *); -char *quote(char *); -char *v_strdup(SCR *, const char *, size_t); -CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t); -enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int); -enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int); -void timepoint_steady(struct timespec *); -void timepoint_system(struct timespec *); -void TRACE(SCR *, const char *, ...); diff --git a/common/gs.h b/common/gs.h index 4d0dc6fe5bf8..c3d10e70048e 100644 --- a/common/gs.h +++ b/common/gs.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: gs.h,v 11.0 2012/10/17 06:34:37 zy Exp $ */ #define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */ @@ -55,8 +53,6 @@ typedef enum { KEY_VEOF, KEY_VERASE, KEY_VKILL, KEY_VWERASE } scr_keyval_t; * Structure that describes global state of the running program. */ struct _gs { - char *progname; /* Programe name. */ - int id; /* Last allocated screen id. */ TAILQ_HEAD(_dqh, _scr) dq[1]; /* Displayed screens. */ TAILQ_HEAD(_hqh, _scr) hq[1]; /* Hidden screens. */ diff --git a/common/key.c b/common/key.c index 790c3719e9b6..23da0498a757 100644 --- a/common/key.c +++ b/common/key.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: key.c,v 10.54 2013/11/13 12:15:27 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -145,10 +141,7 @@ v_key_init(SCR *sp) * in the table, so we check for that first. */ static void -v_keyval( - SCR *sp, - int val, - scr_keyval_t name) +v_keyval(SCR *sp, int val, scr_keyval_t name) { KEYLIST *kp; CHAR_T ch; @@ -206,9 +199,7 @@ v_key_ilookup(SCR *sp) * PUBLIC: size_t v_key_len(SCR *, ARG_CHAR_T); */ size_t -v_key_len( - SCR *sp, - ARG_CHAR_T ch) +v_key_len(SCR *sp, ARG_CHAR_T ch) { (void)v_key_name(sp, ch); return (sp->clen); @@ -222,9 +213,7 @@ v_key_len( * PUBLIC: char *v_key_name(SCR *, ARG_CHAR_T); */ char * -v_key_name( - SCR *sp, - ARG_CHAR_T ach) +v_key_name(SCR *sp, ARG_CHAR_T ach) { static const char hexdigit[] = "0123456789abcdef"; static const char octdigit[] = "01234567"; @@ -330,9 +319,7 @@ done: sp->cname[sp->clen = len] = '\0'; * PUBLIC: e_key_t v_key_val(SCR *, ARG_CHAR_T); */ e_key_t -v_key_val( - SCR *sp, - ARG_CHAR_T ch) +v_key_val(SCR *sp, ARG_CHAR_T ch) { KEYLIST k, *kp; @@ -354,8 +341,7 @@ v_key_val( * PUBLIC: int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int); */ int -v_event_push( - SCR *sp, +v_event_push(SCR *sp, EVENT *p_evp, /* Push event. */ CHAR_T *p_s, /* Push characters. */ size_t nitems, /* Number of items to push. */ @@ -384,8 +370,8 @@ v_event_push( if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64))) return (1); if (gp->i_cnt) - BCOPY(gp->i_event + gp->i_next, - gp->i_event + TERM_PUSH_SHIFT + nitems, gp->i_cnt); + memmove(gp->i_event + TERM_PUSH_SHIFT + nitems, + gp->i_event + gp->i_next, gp->i_cnt * sizeof(EVENT)); gp->i_next = TERM_PUSH_SHIFT; /* Put the new items into the queue. */ @@ -408,9 +394,7 @@ copy: gp->i_cnt += nitems; * Append events onto the tail of the buffer. */ static int -v_event_append( - SCR *sp, - EVENT *argp) +v_event_append(SCR *sp, EVENT *argp) { CHAR_T *s; /* Characters. */ EVENT *evp; @@ -535,11 +519,7 @@ v_event_append( * PUBLIC: int v_event_get(SCR *, EVENT *, int, u_int32_t); */ int -v_event_get( - SCR *sp, - EVENT *argp, - int timeout, - u_int32_t flags) +v_event_get(SCR *sp, EVENT *argp, int timeout, u_int32_t flags) { EVENT *evp, ev; GS *gp; @@ -754,9 +734,7 @@ not_digit: argp->e_c = CH_NOT_DIGIT; * Walk the screen lists, sync'ing files to their backup copies. */ static void -v_sync( - SCR *sp, - int flags) +v_sync(SCR *sp, int flags) { GS *gp; @@ -774,9 +752,7 @@ v_sync( * PUBLIC: void v_event_err(SCR *, EVENT *); */ void -v_event_err( - SCR *sp, - EVENT *evp) +v_event_err(SCR *sp, EVENT *evp) { switch (evp->e_event) { case E_CHARACTER: @@ -813,8 +789,7 @@ v_event_err( } /* Free any allocated memory. */ - if (evp->e_asp != NULL) - free(evp->e_asp); + free(evp->e_asp); } /* @@ -824,9 +799,7 @@ v_event_err( * PUBLIC: int v_event_flush(SCR *, u_int); */ int -v_event_flush( - SCR *sp, - u_int flags) +v_event_flush(SCR *sp, u_int flags) { GS *gp; int rval; @@ -842,9 +815,7 @@ v_event_flush( * Grow the terminal queue. */ static int -v_event_grow( - SCR *sp, - int add) +v_event_grow(SCR *sp, int add) { GS *gp; size_t new_nelem, olen; @@ -862,9 +833,7 @@ v_event_grow( * Compare two keys for sorting. */ static int -v_key_cmp( - const void *ap, - const void *bp) +v_key_cmp(const void *ap, const void *bp) { return (((KEYLIST *)ap)->ch - ((KEYLIST *)bp)->ch); } diff --git a/common/key.h b/common/key.h index 43cef77a4af5..3e55d3044129 100644 --- a/common/key.h +++ b/common/key.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: key.h,v 10.56 2013/11/13 12:15:27 zy Exp $ */ #include "multibyte.h" @@ -159,11 +157,13 @@ extern KEYLIST keylist[]; * can't use the standard isspace(3) macro because it returns true for * characters like ^K in the ASCII character set. The POSIX isblank(3) * has the same problem for non-ASCII locale, so we need a standalone one. - * - * XXX - * Note side effect, ch is evaluated multiple times. */ -#define cmdskip(ch) ((ch) == ' ' || (ch) == '\t') + +static __inline int +cmdskip(CHAR_T ch) +{ + return ch == ' ' || ch == '\t'; +} /* The "standard" tab width, for displaying things to users. */ #define STANDARD_TAB 6 diff --git a/common/line.c b/common/line.c index 5549ad93cb66..06d9a3e692d1 100644 --- a/common/line.c +++ b/common/line.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: line.c,v 10.27 2015/04/03 14:17:21 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -35,8 +31,7 @@ static int scr_update(SCR *, recno_t, lnop_t, int); * PUBLIC: int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *); */ int -db_eget( - SCR *sp, +db_eget(SCR *sp, recno_t lno, /* Line number. */ CHAR_T **pp, /* Pointer store. */ size_t *lenp, /* Length store. */ @@ -79,8 +74,7 @@ db_eget( * PUBLIC: int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *); */ int -db_get( - SCR *sp, +db_get(SCR *sp, recno_t lno, /* Line number. */ u_int32_t flags, CHAR_T **pp, /* Pointer store. */ @@ -202,9 +196,7 @@ err3: if (lenp != NULL) * PUBLIC: int db_delete(SCR *, recno_t); */ int -db_delete( - SCR *sp, - recno_t lno) +db_delete(SCR *sp, recno_t lno) { DBT key; EXF *ep; @@ -258,12 +250,7 @@ db_delete( * PUBLIC: int db_append(SCR *, int, recno_t, CHAR_T *, size_t); */ int -db_append( - SCR *sp, - int update, - recno_t lno, - CHAR_T *p, - size_t len) +db_append(SCR *sp, int update, recno_t lno, CHAR_T *p, size_t len) { DBT data, key; EXF *ep; @@ -334,11 +321,7 @@ db_append( * PUBLIC: int db_insert(SCR *, recno_t, CHAR_T *, size_t); */ int -db_insert( - SCR *sp, - recno_t lno, - CHAR_T *p, - size_t len) +db_insert(SCR *sp, recno_t lno, CHAR_T *p, size_t len) { DBT data, key; EXF *ep; @@ -401,11 +384,7 @@ db_insert( * PUBLIC: int db_set(SCR *, recno_t, CHAR_T *, size_t); */ int -db_set( - SCR *sp, - recno_t lno, - CHAR_T *p, - size_t len) +db_set(SCR *sp, recno_t lno, CHAR_T *p, size_t len) { DBT data, key; EXF *ep; @@ -461,9 +440,7 @@ db_set( * PUBLIC: int db_exist(SCR *, recno_t); */ int -db_exist( - SCR *sp, - recno_t lno) +db_exist(SCR *sp, recno_t lno) { EXF *ep; @@ -496,9 +473,7 @@ db_exist( * PUBLIC: int db_last(SCR *, recno_t *); */ int -db_last( - SCR *sp, - recno_t *lnop) +db_last(SCR *sp, recno_t *lnop) { DBT data, key; EXF *ep; @@ -568,8 +543,7 @@ db_last( * PUBLIC: int db_rget(SCR *, recno_t, char **, size_t *); */ int -db_rget( - SCR *sp, +db_rget(SCR *sp, recno_t lno, /* Line number. */ char **pp, /* Pointer store. */ size_t *lenp) /* Length store. */ @@ -597,11 +571,7 @@ db_rget( * PUBLIC: int db_rset(SCR *, recno_t, char *, size_t); */ int -db_rset( - SCR *sp, - recno_t lno, - char *p, - size_t len) +db_rset(SCR *sp, recno_t lno, char *p, size_t len) { DBT data, key; EXF *ep = sp->ep; @@ -621,9 +591,7 @@ db_rset( * PUBLIC: void db_err(SCR *, recno_t); */ void -db_err( - SCR *sp, - recno_t lno) +db_err(SCR *sp, recno_t lno) { msgq(sp, M_ERR, "008|Error: unable to retrieve line %lu", (u_long)lno); @@ -635,11 +603,7 @@ db_err( * just changed. */ static int -scr_update( - SCR *sp, - recno_t lno, - lnop_t op, - int current) +scr_update(SCR *sp, recno_t lno, lnop_t op, int current) { EXF *ep; SCR *tsp; diff --git a/common/log.c b/common/log.c index 5adfeaf0fc58..5dcd9a2945fc 100644 --- a/common/log.c +++ b/common/log.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: log.c,v 10.27 2011/07/13 06:25:50 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -20,6 +16,7 @@ static const char sccsid[] = "$Id: log.c,v 10.27 2011/07/13 06:25:50 zy Exp $"; #include #include #include +#include #include #include #include @@ -93,9 +90,7 @@ typedef struct { * PUBLIC: int log_init(SCR *, EXF *); */ int -log_init( - SCR *sp, - EXF *ep) +log_init(SCR *sp, EXF *ep) { /* * !!! @@ -129,9 +124,7 @@ log_init( * PUBLIC: int log_end(SCR *, EXF *); */ int -log_end( - SCR *sp, - EXF *ep) +log_end(SCR *sp, EXF *ep) { /* * !!! @@ -141,10 +134,8 @@ log_end( (void)(ep->log->close)(ep->log); ep->log = NULL; } - if (ep->l_lp != NULL) { - free(ep->l_lp); - ep->l_lp = NULL; - } + free(ep->l_lp); + ep->l_lp = NULL; ep->l_len = 0; ep->l_cursor.lno = 1; /* XXX Any valid recno. */ ep->l_cursor.cno = 0; @@ -186,9 +177,7 @@ log_cursor(SCR *sp) * Actually push a cursor record out. */ static int -log_cursor1( - SCR *sp, - int type) +log_cursor1(SCR *sp, int type) { DBT data, key; EXF *ep; @@ -224,10 +213,7 @@ log_cursor1( * PUBLIC: int log_line(SCR *, recno_t, u_int); */ int -log_line( - SCR *sp, - recno_t lno, - u_int action) +log_line(SCR *sp, recno_t lno, u_int action) { DBT data, key; EXF *ep; @@ -327,9 +313,7 @@ log_line( * PUBLIC: int log_mark(SCR *, LMARK *); */ int -log_mark( - SCR *sp, - LMARK *lmp) +log_mark(SCR *sp, LMARK *lmp) { DBT data, key; EXF *ep; @@ -373,9 +357,7 @@ log_mark( * PUBLIC: int log_backward(SCR *, MARK *); */ int -log_backward( - SCR *sp, - MARK *rp) +log_backward(SCR *sp, MARK *rp) { DBT key, data; EXF *ep; @@ -561,9 +543,7 @@ err: F_CLR(ep, F_NOLOG); * PUBLIC: int log_forward(SCR *, MARK *); */ int -log_forward( - SCR *sp, - MARK *rp) +log_forward(SCR *sp, MARK *rp) { DBT key, data; EXF *ep; @@ -658,14 +638,11 @@ err: F_CLR(ep, F_NOLOG); * Try and restart the log on failure, i.e. if we run out of memory. */ static void -log_err( - SCR *sp, - char *file, - int line) +log_err(SCR *sp, char *file, int line) { EXF *ep; - msgq(sp, M_SYSERR, "015|%s/%d: log put error", tail(file), line); + msgq(sp, M_SYSERR, "015|%s/%d: log put error", basename(file), line); ep = sp->ep; (void)ep->log->close(ep->log); if (!log_init(sp, ep)) @@ -674,11 +651,7 @@ log_err( #if defined(DEBUG) && 0 static void -log_trace( - SCR *sp, - char *msg, - recno_t rno, - u_char *p) +log_trace(SCR *sp, char *msg, recno_t rno, u_char *p) { LMARK lm; MARK m; @@ -729,12 +702,8 @@ log_trace( * Apply a realigned line from the log db to the file db. */ static int -apply_with( - int (*db_func)(SCR *, recno_t, CHAR_T *, size_t), - SCR *sp, - recno_t lno, - u_char *p, - size_t len) +apply_with(int (*db_func)(SCR *, recno_t, CHAR_T *, size_t), SCR *sp, + recno_t lno, u_char *p, size_t len) { #ifdef USE_WIDECHAR typedef unsigned long nword; diff --git a/common/log.h b/common/log.h index df307319b1d3..39af1f5dbfdc 100644 --- a/common/log.h +++ b/common/log.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * @(#)log.h 10.2 (Berkeley) 3/6/96 */ #define LOG_NOTYPE 0 diff --git a/common/main.c b/common/main.c index d9ae96f9e7dd..c0b81960bd55 100644 --- a/common/main.c +++ b/common/main.c @@ -9,15 +9,12 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $"; -#endif /* not lint */ - #include #include #include #include +#include #include #include #include @@ -31,8 +28,7 @@ static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $"; #include "pathnames.h" static void attach(GS *); -static void v_estr(char *, int, char *); -static int v_obsolete(char *, char *[]); +static int v_obsolete(char *[]); /* * editor -- @@ -41,10 +37,7 @@ static int v_obsolete(char *, char *[]); * PUBLIC: int editor(GS *, int, char *[]); */ int -editor( - GS *gp, - int argc, - char *argv[]) +editor(GS *gp, int argc, char *argv[]) { extern int optind; extern char *optarg; @@ -82,12 +75,12 @@ editor( /* Set initial screen type and mode based on the program name. */ readonly = 0; - if (!strcmp(gp->progname, "ex") || !strcmp(gp->progname, "nex")) + if (!strcmp(getprogname(), "ex") || !strcmp(getprogname(), "nex")) LF_INIT(SC_EX); else { /* Nview, view are readonly. */ - if (!strcmp(gp->progname, "nview") || - !strcmp(gp->progname, "view")) + if (!strcmp(getprogname(), "nview") || + !strcmp(getprogname(), "view")) readonly = 1; /* Vi is the default. */ @@ -95,7 +88,7 @@ editor( } /* Convert old-style arguments into new-style ones. */ - if (v_obsolete(gp->progname, argv)) + if (v_obsolete(argv)) return (1); /* Parse the arguments. */ @@ -119,8 +112,7 @@ editor( * We should support multiple -c options. */ if (gp->c_option != NULL) { - v_estr(gp->progname, 0, - "only one -c command may be specified."); + warnx("only one -c command may be specified."); return (1); } gp->c_option = optarg; @@ -135,8 +127,7 @@ editor( attach(gp); break; default: - v_estr(gp->progname, 0, - "usage: -D requires s or w argument."); + warnx("usage: -D requires s or w argument."); return (1); } break; @@ -156,8 +147,7 @@ editor( break; case 'r': /* Recover. */ if (flagchk == 't') { - v_estr(gp->progname, 0, - "only one of -r and -t may be specified."); + warnx("only one of -r and -t may be specified."); return (1); } flagchk = 'r'; @@ -171,7 +161,7 @@ editor( #ifdef DEBUG case 'T': /* Trace. */ if ((gp->tracefp = fopen(optarg, "w")) == NULL) { - v_estr(gp->progname, errno, optarg); + warn("%s", optarg); goto err; } (void)fprintf(gp->tracefp, @@ -180,13 +170,11 @@ editor( #endif case 't': /* Tag. */ if (flagchk == 'r') { - v_estr(gp->progname, 0, - "only one of -r and -t may be specified."); + warnx("only one of -r and -t may be specified."); return (1); } if (flagchk == 't') { - v_estr(gp->progname, 0, - "only one tag file may be specified."); + warnx("only one tag file may be specified."); return (1); } flagchk = 't'; @@ -213,7 +201,7 @@ editor( * If not reading from a terminal, it's like -s was specified. */ if (silent && !LF_ISSET(SC_EX)) { - v_estr(gp->progname, 0, "-s option is only applicable to ex."); + warnx("-s option is only applicable to ex."); goto err; } if (LF_ISSET(SC_EX) && F_ISSET(gp, G_SCRIPTED)) @@ -341,7 +329,7 @@ editor( /* Cheat -- we know we have an extra argv slot. */ *--argv = strdup(sp->frp->name); if (*argv == NULL) { - v_estr(gp->progname, errno, NULL); + warn(NULL); goto err; } } @@ -452,17 +440,14 @@ v_end(gp) /* Free FREF's. */ while ((frp = TAILQ_FIRST(gp->frefq)) != NULL) { TAILQ_REMOVE(gp->frefq, frp, q); - if (frp->name != NULL) - free(frp->name); - if (frp->tname != NULL) - free(frp->tname); + free(frp->name); + free(frp->tname); free(frp); } } /* Free key input queue. */ - if (gp->i_event != NULL) - free(gp->i_event); + free(gp->i_event); /* Free cut buffers. */ cut_close(gp); @@ -499,8 +484,7 @@ v_end(gp) #if defined(DEBUG) || defined(PURIFY) /* Free any temporary space. */ - if (gp->tmp_bp != NULL) - free(gp->tmp_bp); + free(gp->tmp_bp); #if defined(DEBUG) /* Close debugging file descriptor. */ @@ -515,9 +499,7 @@ v_end(gp) * Convert historic arguments into something getopt(3) will like. */ static int -v_obsolete( - char *name, - char *argv[]) +v_obsolete(char *argv[]) { size_t len; char *p; @@ -555,7 +537,7 @@ v_obsolete( if (argv[0][1] == '\0') { argv[0] = strdup("-s"); if (argv[0] == NULL) { -nomem: v_estr(name, errno, NULL); +nomem: warn(NULL); return (1); } } else @@ -574,7 +556,7 @@ attach(GS *gp) char ch; if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) { - v_estr(gp->progname, errno, _PATH_TTY); + warn("%s", _PATH_TTY); return; } @@ -591,17 +573,3 @@ attach(GS *gp) (void)close(fd); } #endif - -static void -v_estr( - char *name, - int eno, - char *msg) -{ - (void)fprintf(stderr, "%s", name); - if (msg != NULL) - (void)fprintf(stderr, ": %s", msg); - if (eno) - (void)fprintf(stderr, ": %s", strerror(errno)); - (void)fprintf(stderr, "\n"); -} diff --git a/common/mark.c b/common/mark.c index a3158e4560b6..9af4612cb22a 100644 --- a/common/mark.c +++ b/common/mark.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: mark.c,v 10.14 2011/07/04 14:42:58 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -66,9 +62,7 @@ static LMARK *mark_find(SCR *, ARG_CHAR_T); * PUBLIC: int mark_init(SCR *, EXF *); */ int -mark_init( - SCR *sp, - EXF *ep) +mark_init(SCR *sp, EXF *ep) { /* * !!! @@ -87,9 +81,7 @@ mark_init( * PUBLIC: int mark_end(SCR *, EXF *); */ int -mark_end( - SCR *sp, - EXF *ep) +mark_end(SCR *sp, EXF *ep) { LMARK *lmp; @@ -111,11 +103,7 @@ mark_end( * PUBLIC: int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t); */ int -mark_get( - SCR *sp, - ARG_CHAR_T key, - MARK *mp, - mtype_t mtype) +mark_get(SCR *sp, ARG_CHAR_T key, MARK *mp, mtype_t mtype) { LMARK *lmp; @@ -156,11 +144,7 @@ mark_get( * PUBLIC: int mark_set(SCR *, ARG_CHAR_T, MARK *, int); */ int -mark_set( - SCR *sp, - ARG_CHAR_T key, - MARK *value, - int userset) +mark_set(SCR *sp, ARG_CHAR_T key, MARK *value, int userset) { LMARK *lmp, *lmt; @@ -175,7 +159,7 @@ mark_set( */ lmp = mark_find(sp, key); if (lmp == NULL || lmp->name != key) { - MALLOC_RET(sp, lmt, LMARK *, sizeof(LMARK)); + MALLOC_RET(sp, lmt, sizeof(LMARK)); if (lmp == NULL) { SLIST_INSERT_HEAD(sp->ep->marks, lmt, q); } else @@ -198,9 +182,7 @@ mark_set( * where it would go. */ static LMARK * -mark_find( - SCR *sp, - ARG_CHAR_T key) +mark_find(SCR *sp, ARG_CHAR_T key) { LMARK *lmp, *lastlmp = NULL; @@ -223,10 +205,7 @@ mark_find( * PUBLIC: int mark_insdel(SCR *, lnop_t, recno_t); */ int -mark_insdel( - SCR *sp, - lnop_t op, - recno_t lno) +mark_insdel(SCR *sp, lnop_t op, recno_t lno) { LMARK *lmp; recno_t lline; diff --git a/common/mark.h b/common/mark.h index 44b8a19938ca..53a07836c625 100644 --- a/common/mark.h +++ b/common/mark.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: mark.h,v 10.6 2011/07/04 14:41:51 zy Exp $ */ /* diff --git a/common/mem.h b/common/mem.h index b2b44b62ec8e..1e26a6ea6549 100644 --- a/common/mem.h +++ b/common/mem.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: mem.h,v 10.17 2012/10/07 00:40:29 zy Exp $ */ #ifdef DEBUG @@ -148,45 +146,32 @@ /* * Malloc a buffer, casting the return pointer. Various versions. - * - * !!! - * The cast should be unnecessary, malloc(3) and friends return void *'s, - * which is all we need. However, some systems that nvi needs to run on - * don't do it right yet, resulting in the compiler printing out roughly - * a million warnings. After awhile, it seemed easier to put the casts - * in instead of explaining it all the time. */ -#define CALLOC(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) \ +#define CALLOC(sp, p, nmemb, size) { \ + if ((p = calloc(nmemb, size)) == NULL) \ msgq(sp, M_SYSERR, NULL); \ } -#define CALLOC_GOTO(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) \ +#define CALLOC_GOTO(sp, p, nmemb, size) { \ + if ((p = calloc(nmemb, size)) == NULL) \ goto alloc_err; \ } -#define CALLOC_NOMSG(sp, p, cast, nmemb, size) { \ - p = (cast)calloc(nmemb, size); \ -} -#define CALLOC_RET(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) { \ +#define CALLOC_RET(sp, p, nmemb, size) { \ + if ((p = calloc(nmemb, size)) == NULL) { \ msgq(sp, M_SYSERR, NULL); \ return (1); \ } \ } -#define MALLOC(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) \ +#define MALLOC(sp, p, size) { \ + if ((p = malloc(size)) == NULL) \ msgq(sp, M_SYSERR, NULL); \ } -#define MALLOC_GOTO(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) \ +#define MALLOC_GOTO(sp, p, size) { \ + if ((p = malloc(size)) == NULL) \ goto alloc_err; \ } -#define MALLOC_NOMSG(sp, p, cast, size) { \ - p = (cast)malloc(size); \ -} -#define MALLOC_RET(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) { \ +#define MALLOC_RET(sp, p, size) { \ + if ((p = malloc(size)) == NULL) { \ msgq(sp, M_SYSERR, NULL); \ return (1); \ } \ @@ -198,21 +183,13 @@ */ #define REALLOC(sp, p, cast, size) { \ cast newp; \ - if ((newp = (cast)realloc(p, size)) == NULL) { \ - if (p != NULL) \ - free(p); \ + if ((newp = realloc(p, size)) == NULL) { \ + free(p); \ msgq(sp, M_SYSERR, NULL); \ } \ p = newp; \ } -/* - * Versions of bcopy(3) and bzero(3) that use the size of the - * initial pointer to figure out how much memory to manipulate. - */ -#define BCOPY(p, t, len) bcopy(p, t, (len) * sizeof(*(p))) -#define BZERO(p, len) bzero(p, (len) * sizeof(*(p))) - /* * p2roundup -- * Get next power of 2; convenient for realloc. diff --git a/common/msg.c b/common/msg.c index 3099b1e98b3c..d2463a3ecccd 100644 --- a/common/msg.c +++ b/common/msg.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: msg.c,v 11.1 2015/02/09 11:12:44 marc Exp $"; -#endif /* not lint */ - #include #include #include @@ -39,11 +35,7 @@ static const char sccsid[] = "$Id: msg.c,v 11.1 2015/02/09 11:12:44 marc Exp $"; * PUBLIC: void msgq(SCR *, mtype_t, const char *, ...); */ void -msgq( - SCR *sp, - mtype_t mt, - const char *fmt, - ...) +msgq(SCR *sp, mtype_t mt, const char *fmt, ...) { #ifndef NL_ARGMAX #define __NL_ARGMAX 20 /* Set to 9 by System V. */ @@ -202,12 +194,12 @@ retry: FREE_SPACE(sp, bp, blen); if (*p == '\0') break; ++p; - if (!isdigit(*p)) { + if (!isdigit((u_char)*p)) { if (*p == '%') ++p; continue; } - for (u = p; *++p != '\0' && isdigit(*p);); + for (u = p; *++p != '\0' && isdigit((u_char)*p);); if (*p != '$') continue; @@ -359,11 +351,7 @@ nofmt: mp += len; * PUBLIC: void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *); */ void -msgq_wstr( - SCR *sp, - mtype_t mtype, - const CHAR_T *str, - const char *fmt) +msgq_wstr(SCR *sp, mtype_t mtype, const CHAR_T *str, const char *fmt) { size_t nlen; CONST char *nstr; @@ -383,11 +371,7 @@ msgq_wstr( * PUBLIC: void msgq_str(SCR *, mtype_t, const char *, const char *); */ void -msgq_str( - SCR *sp, - mtype_t mtype, - const char *str, - const char *fmt) +msgq_str(SCR *sp, mtype_t mtype, const char *str, const char *fmt) { int nf, sv_errno; char *p; @@ -536,10 +520,7 @@ mod_rpt(SCR *sp) * PUBLIC: void msgq_status(SCR *, recno_t, u_int); */ void -msgq_status( - SCR *sp, - recno_t lno, - u_int flags) +msgq_status(SCR *sp, recno_t lno, u_int flags) { recno_t last; size_t blen, len; @@ -708,9 +689,7 @@ msgq_status( * PUBLIC: int msg_open(SCR *, char *); */ int -msg_open( - SCR *sp, - char *file) +msg_open(SCR *sp, char *file) { /* * !!! @@ -788,10 +767,7 @@ msg_close(GS *gp) * PUBLIC: const char *msg_cmsg(SCR *, cmsg_t, size_t *); */ const char * -msg_cmsg( - SCR *sp, - cmsg_t which, - size_t *lenp) +msg_cmsg(SCR *sp, cmsg_t which, size_t *lenp) { switch (which) { case CMSG_CONF: @@ -826,10 +802,7 @@ msg_cmsg( * PUBLIC: const char *msg_cat(SCR *, const char *, size_t *); */ const char * -msg_cat( - SCR *sp, - const char *str, - size_t *lenp) +msg_cat(SCR *sp, const char *str, size_t *lenp) { GS *gp; char *p; @@ -839,8 +812,9 @@ msg_cat( * If it's not a catalog message, i.e. has doesn't have a leading * number and '|' symbol, we're done. */ - if (isdigit(str[0]) && - isdigit(str[1]) && isdigit(str[2]) && str[3] == '|') { + if (isdigit((u_char)str[0]) && + isdigit((u_char)str[1]) && + isdigit((u_char)str[2]) && str[3] == '|') { msgno = atoi(str); str = &str[4]; @@ -864,10 +838,7 @@ msg_cat( * PUBLIC: char *msg_print(SCR *, const char *, int *); */ char * -msg_print( - SCR *sp, - const char *s, - int *needfree) +msg_print(SCR *sp, const char *s, int *needfree) { size_t blen, nlen; char *bp, *ep, *p, *t; diff --git a/common/msg.h b/common/msg.h index d65bb1aaf542..f0f8a308e586 100644 --- a/common/msg.h +++ b/common/msg.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * @(#)msg.h 10.10 (Berkeley) 5/10/96 */ /* diff --git a/common/multibyte.h b/common/multibyte.h index 40e352100ec3..4967818f3e6a 100644 --- a/common/multibyte.h +++ b/common/multibyte.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: multibyte.h,v 1.32 2012/10/07 01:35:58 zy Exp $ */ #ifndef MULTIBYTE_H @@ -112,4 +110,38 @@ typedef char RCHAR_T; #define SIZE(w) (sizeof(w) / sizeof(*w)) +/* + * Locale insensitive character category detection. + */ + +static __inline int +isatoz(CHAR_T c) +{ + return 'a' <= c && c <= 'z'; +} + +static __inline int +isAtoZ(CHAR_T c) +{ + return 'A' <= c && c <= 'Z'; +} + +static __inline int +is0to9(CHAR_T c) +{ + return '0' <= c && c <= '9'; +} + +static __inline int +isazAZ(CHAR_T c) +{ + return isatoz(c) || isAtoZ(c); +} + +static __inline int +is09azAZ(CHAR_T c) +{ + return is0to9(c) || isazAZ(c); +} + #endif diff --git a/common/options.c b/common/options.c index e619d8f08eb7..25b10fe67012 100644 --- a/common/options.c +++ b/common/options.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: options.c,v 10.73 2012/10/09 06:14:07 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -79,6 +75,8 @@ OPTLIST const optlist[] = { {L("errorbells"), NULL, OPT_0BOOL, 0}, /* O_ESCAPETIME 4.4BSD */ {L("escapetime"), NULL, OPT_NUM, 0}, +/* O_EXPANDTAB NetBSD 5.0 */ + {L("expandtab"), NULL, OPT_0BOOL, 0}, /* O_EXRC System V (undocumented) */ {L("exrc"), NULL, OPT_0BOOL, 0}, /* O_EXTENDED 4.4BSD */ @@ -256,6 +254,7 @@ static OABBREV const abbrev[] = { {L("dir"), O_TMPDIR}, /* 4BSD */ {L("eb"), O_ERRORBELLS}, /* 4BSD */ {L("ed"), O_EDCOMPATIBLE}, /* 4BSD */ + {L("et"), O_EXPANDTAB}, /* NetBSD 5.0 */ {L("ex"), O_EXRC}, /* System V (undocumented) */ {L("fe"), O_FILEENCODING}, {L("ht"), O_HARDTABS}, /* 4BSD */ @@ -297,9 +296,7 @@ static OABBREV const abbrev[] = { * PUBLIC: int opts_init(SCR *, int *); */ int -opts_init( - SCR *sp, - int *oargs) +opts_init(SCR *sp, int *oargs) { ARGS *argv[2], a, b; OPTLIST const *op; @@ -463,10 +460,7 @@ err: msgq_wstr(sp, M_ERR, optlist[optindx].name, * PUBLIC: int opts_set(SCR *, ARGS *[], char *); */ int -opts_set( - SCR *sp, - ARGS *argv[], - char *usage) +opts_set(SCR *sp, ARGS *argv[], char *usage) { enum optdisp disp; enum nresult nret; @@ -757,12 +751,7 @@ badnum: INT2CHAR(sp, name, STRLEN(name) + 1, * PUBLIC: int o_set(SCR *, int, u_int, char *, u_long); */ int -o_set( - SCR *sp, - int opt, - u_int flags, - char *str, - u_long val) +o_set(SCR *sp, int opt, u_int flags, char *str, u_long val) { OPTION *op; @@ -779,14 +768,14 @@ o_set( /* Free the previous string, if requested, and set the value. */ if LF_ISSET(OS_DEF) if (LF_ISSET(OS_STR | OS_STRDUP)) { - if (!LF_ISSET(OS_NOFREE) && op->o_def.str != NULL) + if (!LF_ISSET(OS_NOFREE)) free(op->o_def.str); op->o_def.str = str; } else op->o_def.val = val; else if (LF_ISSET(OS_STR | OS_STRDUP)) { - if (!LF_ISSET(OS_NOFREE) && op->o_cur.str != NULL) + if (!LF_ISSET(OS_NOFREE)) free(op->o_cur.str); op->o_cur.str = str; } else @@ -801,10 +790,7 @@ o_set( * PUBLIC: int opts_empty(SCR *, int, int); */ int -opts_empty( - SCR *sp, - int off, - int silent) +opts_empty(SCR *sp, int off, int silent) { char *p; @@ -824,9 +810,7 @@ opts_empty( * PUBLIC: void opts_dump(SCR *, enum optdisp); */ void -opts_dump( - SCR *sp, - enum optdisp type) +opts_dump(SCR *sp, enum optdisp type) { OPTLIST const *op; int base, b_num, cnt, col, colwidth, curlen, s_num; @@ -958,9 +942,7 @@ opts_dump( * Print out an option. */ static int -opts_print( - SCR *sp, - OPTLIST const *op) +opts_print(SCR *sp, OPTLIST const *op) { int curlen, offset; @@ -990,9 +972,7 @@ opts_print( * PUBLIC: int opts_save(SCR *, FILE *); */ int -opts_save( - SCR *sp, - FILE *fp) +opts_save(SCR *sp, FILE *fp) { OPTLIST const *op; CHAR_T ch, *p; @@ -1093,26 +1073,20 @@ opts_search(CHAR_T *name) * PUBLIC: void opts_nomatch(SCR *, CHAR_T *); */ void -opts_nomatch( - SCR *sp, - CHAR_T *name) +opts_nomatch(SCR *sp, CHAR_T *name) { msgq_wstr(sp, M_ERR, name, "033|set: no %s option: 'set all' gives all option values"); } static int -opts_abbcmp( - const void *a, - const void *b) +opts_abbcmp(const void *a, const void *b) { return(STRCMP(((OABBREV *)a)->name, ((OABBREV *)b)->name)); } static int -opts_cmp( - const void *a, - const void *b) +opts_cmp(const void *a, const void *b) { return(STRCMP(((OPTLIST *)a)->name, ((OPTLIST *)b)->name)); } @@ -1124,9 +1098,7 @@ opts_cmp( * PUBLIC: int opts_copy(SCR *, SCR *); */ int -opts_copy( - SCR *orig, - SCR *sp) +opts_copy(SCR *orig, SCR *sp) { int cnt, rval; @@ -1180,9 +1152,7 @@ opts_free(SCR *sp) if (optlist[cnt].type != OPT_STR || F_ISSET(&sp->opts[cnt], OPT_GLOBAL)) continue; - if (O_STR(sp, cnt) != NULL) - free(O_STR(sp, cnt)); - if (O_D_STR(sp, cnt) != NULL) - free(O_D_STR(sp, cnt)); + free(O_STR(sp, cnt)); + free(O_D_STR(sp, cnt)); } } diff --git a/common/options.h b/common/options.h index aaeece144d89..5ed12d39c342 100644 --- a/common/options.h +++ b/common/options.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: options.h,v 10.21 2012/02/10 20:24:58 zy Exp $ */ /* diff --git a/common/options_def.h b/common/options_def.h deleted file mode 100644 index 8e232786cfe6..000000000000 --- a/common/options_def.h +++ /dev/null @@ -1,83 +0,0 @@ -#define O_ALTWERASE 0 -#define O_AUTOINDENT 1 -#define O_AUTOPRINT 2 -#define O_AUTOWRITE 3 -#define O_BACKUP 4 -#define O_BEAUTIFY 5 -#define O_CDPATH 6 -#define O_CEDIT 7 -#define O_COLUMNS 8 -#define O_COMBINED 9 -#define O_COMMENT 10 -#define O_TMPDIR 11 -#define O_EDCOMPATIBLE 12 -#define O_ERRORBELLS 13 -#define O_ESCAPETIME 14 -#define O_EXRC 15 -#define O_EXTENDED 16 -#define O_FILEC 17 -#define O_FILEENCODING 18 -#define O_FLASH 19 -#define O_HARDTABS 20 -#define O_ICLOWER 21 -#define O_IGNORECASE 22 -#define O_INPUTENCODING 23 -#define O_KEYTIME 24 -#define O_LEFTRIGHT 25 -#define O_LINES 26 -#define O_LISP 27 -#define O_LIST 28 -#define O_LOCKFILES 29 -#define O_MAGIC 30 -#define O_MATCHCHARS 31 -#define O_MATCHTIME 32 -#define O_MESG 33 -#define O_MODELINE 34 -#define O_MSGCAT 35 -#define O_NOPRINT 36 -#define O_NUMBER 37 -#define O_OCTAL 38 -#define O_OPEN 39 -#define O_OPTIMIZE 40 -#define O_PARAGRAPHS 41 -#define O_PATH 42 -#define O_PRINT 43 -#define O_PROMPT 44 -#define O_READONLY 45 -#define O_RECDIR 46 -#define O_REDRAW 47 -#define O_REMAP 48 -#define O_REPORT 49 -#define O_RULER 50 -#define O_SCROLL 51 -#define O_SEARCHINCR 52 -#define O_SECTIONS 53 -#define O_SECURE 54 -#define O_SHELL 55 -#define O_SHELLMETA 56 -#define O_SHIFTWIDTH 57 -#define O_SHOWMATCH 58 -#define O_SHOWMODE 59 -#define O_SIDESCROLL 60 -#define O_SLOWOPEN 61 -#define O_SOURCEANY 62 -#define O_TABSTOP 63 -#define O_TAGLENGTH 64 -#define O_TAGS 65 -#define O_TERM 66 -#define O_TERSE 67 -#define O_TILDEOP 68 -#define O_TIMEOUT 69 -#define O_TTYWERASE 70 -#define O_VERBOSE 71 -#define O_W1200 72 -#define O_W300 73 -#define O_W9600 74 -#define O_WARN 75 -#define O_WINDOW 76 -#define O_WINDOWNAME 77 -#define O_WRAPLEN 78 -#define O_WRAPMARGIN 79 -#define O_WRAPSCAN 80 -#define O_WRITEANY 81 -#define O_OPTIONCOUNT 82 diff --git a/common/options_f.c b/common/options_f.c index 850bfc2eca5c..45ab913c55ab 100644 --- a/common/options_f.c +++ b/common/options_f.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: options_f.c,v 10.34 04/07/11 16:06:29 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -32,11 +28,7 @@ static const char sccsid[] = "$Id: options_f.c,v 10.34 04/07/11 16:06:29 zy Exp * PUBLIC: int f_altwerase(SCR *, OPTION *, char *, u_long *); */ int -f_altwerase( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_altwerase(SCR *sp, OPTION *op, char *str, u_long *valp) { if (*valp) O_CLR(sp, O_TTYWERASE); @@ -47,11 +39,7 @@ f_altwerase( * PUBLIC: int f_columns(SCR *, OPTION *, char *, u_long *); */ int -f_columns( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_columns(SCR *sp, OPTION *op, char *str, u_long *valp) { /* Validate the number. */ if (*valp < MINIMUM_SCREEN_COLS) { @@ -81,11 +69,7 @@ f_columns( * PUBLIC: int f_lines(SCR *, OPTION *, char *, u_long *); */ int -f_lines( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_lines(SCR *sp, OPTION *op, char *str, u_long *valp) { /* Validate the number. */ if (*valp < MINIMUM_SCREEN_ROWS) { @@ -138,11 +122,7 @@ f_lines( * PUBLIC: int f_lisp(SCR *, OPTION *, char *, u_long *); */ int -f_lisp( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_lisp(SCR *sp, OPTION *op, char *str, u_long *valp) { msgq(sp, M_ERR, "044|The lisp option is not implemented"); return (0); @@ -152,11 +132,7 @@ f_lisp( * PUBLIC: int f_msgcat(SCR *, OPTION *, char *, u_long *); */ int -f_msgcat( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_msgcat(SCR *sp, OPTION *op, char *str, u_long *valp) { (void)msg_open(sp, str); return (0); @@ -166,11 +142,7 @@ f_msgcat( * PUBLIC: int f_print(SCR *, OPTION *, char *, u_long *); */ int -f_print( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_print(SCR *sp, OPTION *op, char *str, u_long *valp) { int offset = op - sp->opts; @@ -195,11 +167,7 @@ f_print( * PUBLIC: int f_readonly(SCR *, OPTION *, char *, u_long *); */ int -f_readonly( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_readonly(SCR *sp, OPTION *op, char *str, u_long *valp) { /* * !!! @@ -216,11 +184,7 @@ f_readonly( * PUBLIC: int f_recompile(SCR *, OPTION *, char *, u_long *); */ int -f_recompile( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_recompile(SCR *sp, OPTION *op, char *str, u_long *valp) { if (F_ISSET(sp, SC_RE_SEARCH)) { regfree(&sp->re_c); @@ -237,11 +201,7 @@ f_recompile( * PUBLIC: int f_reformat(SCR *, OPTION *, char *, u_long *); */ int -f_reformat( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_reformat(SCR *sp, OPTION *op, char *str, u_long *valp) { F_SET(sp, SC_SCR_REFORMAT); return (0); @@ -251,11 +211,7 @@ f_reformat( * PUBLIC: int f_ttywerase(SCR *, OPTION *, char *, u_long *); */ int -f_ttywerase( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_ttywerase(SCR *sp, OPTION *op, char *str, u_long *valp) { if (*valp) O_CLR(sp, O_ALTWERASE); @@ -266,11 +222,7 @@ f_ttywerase( * PUBLIC: int f_w300(SCR *, OPTION *, char *, u_long *); */ int -f_w300( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_w300(SCR *sp, OPTION *op, char *str, u_long *valp) { u_long v; @@ -287,11 +239,7 @@ f_w300( * PUBLIC: int f_w1200(SCR *, OPTION *, char *, u_long *); */ int -f_w1200( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_w1200(SCR *sp, OPTION *op, char *str, u_long *valp) { u_long v; @@ -308,11 +256,7 @@ f_w1200( * PUBLIC: int f_w9600(SCR *, OPTION *, char *, u_long *); */ int -f_w9600( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_w9600(SCR *sp, OPTION *op, char *str, u_long *valp) { u_long v; @@ -329,11 +273,7 @@ f_w9600( * PUBLIC: int f_window(SCR *, OPTION *, char *, u_long *); */ int -f_window( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_window(SCR *sp, OPTION *op, char *str, u_long *valp) { if (*valp >= O_VAL(sp, O_LINES) - 1 && (*valp = O_VAL(sp, O_LINES) - 1) == 0) @@ -345,11 +285,7 @@ f_window( * PUBLIC: int f_encoding(SCR *, OPTION *, char *, u_long *); */ int -f_encoding( - SCR *sp, - OPTION *op, - char *str, - u_long *valp) +f_encoding(SCR *sp, OPTION *op, char *str, u_long *valp) { int offset = op - sp->opts; diff --git a/common/put.c b/common/put.c index d3adf5c08607..26a67ac8711c 100644 --- a/common/put.c +++ b/common/put.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: put.c,v 10.19 04/07/11 17:00:24 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -33,13 +29,7 @@ static const char sccsid[] = "$Id: put.c,v 10.19 04/07/11 17:00:24 zy Exp $"; * PUBLIC: int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int); */ int -put( - SCR *sp, - CB *cbp, - CHAR_T *namep, - MARK *cp, - MARK *rp, - int append) +put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append) { CHAR_T name; TEXT *ltp, *tp; diff --git a/common/recover.c b/common/recover.c index d0a927bd4301..89f25a4146e9 100644 --- a/common/recover.c +++ b/common/recover.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: recover.c,v 11.3 2015/04/04 03:50:42 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -116,10 +112,7 @@ static int rcv_dlnread(SCR *, char **, char **, FILE *); * PUBLIC: int rcv_tmp(SCR *, EXF *, char *); */ int -rcv_tmp( - SCR *sp, - EXF *ep, - char *name) +rcv_tmp(SCR *sp, EXF *ep, char *name) { struct stat sb; int fd; @@ -237,9 +230,7 @@ err: msgq(sp, M_ERR, * PUBLIC: int rcv_sync(SCR *, u_int); */ int -rcv_sync( - SCR *sp, - u_int flags) +rcv_sync(SCR *sp, u_int flags) { EXF *ep; int fd, rval; @@ -318,10 +309,7 @@ err: rval = 1; * Build the file to mail to the user. */ static int -rcv_mailfile( - SCR *sp, - int issync, - char *cp_path) +rcv_mailfile(SCR *sp, int issync, char *cp_path) { EXF *ep; GS *gp; @@ -404,7 +392,7 @@ rcv_mailfile( goto err; } - MALLOC(sp, host, char *, hostmax + 1); + MALLOC(sp, host, hostmax + 1); if (host == NULL) goto err; (void)gethostname(host, hostmax + 1); @@ -429,8 +417,8 @@ rcv_mailfile( " was editing a file named ", t, " on the machine ", host, ", when it was saved for recovery. ", "You can recover most, if not all, of the changes ", - "to this file using the -r option to ", gp->progname, ":\n\n\t", - gp->progname, " -r ", qt); + "to this file using the -r option to ", getprogname(), ":\n\n\t", + getprogname(), " -r ", qt); free(qt); free(host); if (buf == NULL) { @@ -594,13 +582,11 @@ rcv_list(SCR *sp) /* Close, discarding lock. */ next: (void)fclose(fp); - if (file != NULL) - free(file); - if (path != NULL) - free(path); + free(file); + free(path); } if (found == 0) - (void)printf("%s: No files to recover\n", sp->gp->progname); + (void)printf("%s: No files to recover\n", getprogname()); (void)closedir(dirp); return (0); } @@ -612,9 +598,7 @@ next: (void)fclose(fp); * PUBLIC: int rcv_read(SCR *, FREF *); */ int -rcv_read( - SCR *sp, - FREF *frp) +rcv_read(SCR *sp, FREF *frp) { struct dirent *dp; struct stat sb; @@ -732,12 +716,10 @@ rcv_read( sv_fd = dup(fileno(fp)); } else { next: free(recpath); - if (path != NULL) - free(path); + free(path); } (void)fclose(fp); - if (file != NULL) - free(file); + free(file); } (void)closedir(dirp); @@ -790,10 +772,7 @@ next: free(recpath); * Copy a recovery file. */ static int -rcv_copy( - SCR *sp, - int wfd, - char *fname) +rcv_copy(SCR *sp, int wfd, char *fname) { int nr, nw, off, rfd; char buf[8 * 1024]; @@ -816,10 +795,7 @@ err: msgq_str(sp, M_SYSERR, fname, "%s"); * Paranoid make temporary file routine. */ static int -rcv_mktemp( - SCR *sp, - char *path, - char *dname) +rcv_mktemp(SCR *sp, char *path, char *dname) { int fd; @@ -833,9 +809,7 @@ rcv_mktemp( * Send email. */ static void -rcv_email( - SCR *sp, - char *fname) +rcv_email(SCR *sp, char *fname) { char *buf; @@ -854,11 +828,7 @@ rcv_email( * Encode a string into an X-vi-data line and write it. */ static int -rcv_dlnwrite( - SCR *sp, - const char *dtype, - const char *src, - FILE *fp) +rcv_dlnwrite(SCR *sp, const char *dtype, const char *src, FILE *fp) { char *bp = NULL, *p; size_t blen = 0; @@ -901,9 +871,7 @@ err: FREE_SPACE(sp, bp, blen); * Read an X-vi-data line and decode it. */ static int -rcv_dlnread( - SCR *sp, - char **dtypep, +rcv_dlnread(SCR *sp, char **dtypep, char **datap, /* free *datap if != NULL after use. */ FILE *fp) { @@ -948,7 +916,7 @@ rcv_dlnread( len -= src - bp; /* Memory looks like: "\0\0". */ - MALLOC(sp, data, char *, dlen + len / 4 * 3 + 2); + MALLOC(sp, data, dlen + len / 4 * 3 + 2); if (data == NULL) goto err; if ((xlen = (b64_pton(p + dlen + 1, diff --git a/common/screen.c b/common/screen.c index ae6fb207567f..0d0da0a56def 100644 --- a/common/screen.c +++ b/common/screen.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -35,16 +31,13 @@ static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $ * PUBLIC: int screen_init(GS *, SCR *, SCR **); */ int -screen_init( - GS *gp, - SCR *orig, - SCR **spp) +screen_init(GS *gp, SCR *orig, SCR **spp) { SCR *sp; size_t len; *spp = NULL; - CALLOC_RET(orig, sp, SCR *, 1, sizeof(SCR)); + CALLOC_RET(orig, sp, 1, sizeof(SCR)); *spp = sp; /* INITIALIZED AT SCREEN CREATE. */ @@ -94,7 +87,7 @@ screen_init( sp->repl_len = orig->repl_len; if (orig->newl_len) { len = orig->newl_len * sizeof(size_t); - MALLOC(sp, sp->newl, size_t *, len); + MALLOC(sp, sp->newl, len); if (sp->newl == NULL) { mem: msgq(orig, M_SYSERR, NULL); goto err; @@ -172,22 +165,17 @@ screen_end(SCR *sp) text_lfree(sp->tiq); /* Free alternate file name. */ - if (sp->alt_name != NULL) - free(sp->alt_name); + free(sp->alt_name); /* Free up search information. */ - if (sp->re != NULL) - free(sp->re); + free(sp->re); if (F_ISSET(sp, SC_RE_SEARCH)) regfree(&sp->re_c); - if (sp->subre != NULL) - free(sp->subre); + free(sp->subre); if (F_ISSET(sp, SC_RE_SUBST)) regfree(&sp->subre_c); - if (sp->repl != NULL) - free(sp->repl); - if (sp->newl != NULL) - free(sp->newl); + free(sp->repl); + free(sp->newl); /* Free the iconv environment */ conv_end(sp); diff --git a/common/screen.h b/common/screen.h index a762706834dd..94512a7c0cfb 100644 --- a/common/screen.h +++ b/common/screen.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: screen.h,v 10.26 2011/12/12 22:31:36 zy Exp $ */ /* diff --git a/common/search.c b/common/search.c index 4831a0874aae..e8dcac431f51 100644 --- a/common/search.c +++ b/common/search.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: search.c,v 10.27 2015/03/13 18:41:35 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -38,13 +34,8 @@ static int search_init(SCR *, dir_t, CHAR_T *, size_t, CHAR_T **, u_int); * Set up a search. */ static int -search_init( - SCR *sp, - dir_t dir, - CHAR_T *ptrn, - size_t plen, - CHAR_T **epp, - u_int flags) +search_init(SCR *sp, dir_t dir, CHAR_T *ptrn, size_t plen, CHAR_T **epp, + u_int flags) { recno_t lno; int delim; @@ -146,14 +137,8 @@ prev: if (sp->re == NULL) { * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); */ int -f_search( - SCR *sp, - MARK *fm, - MARK *rm, - CHAR_T *ptrn, - size_t plen, - CHAR_T **eptrn, - u_int flags) +f_search(SCR *sp, MARK *fm, MARK *rm, CHAR_T *ptrn, size_t plen, + CHAR_T **eptrn, u_int flags) { busy_t btype; recno_t lno; @@ -293,14 +278,8 @@ f_search( * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int); */ int -b_search( - SCR *sp, - MARK *fm, - MARK *rm, - CHAR_T *ptrn, - size_t plen, - CHAR_T **eptrn, - u_int flags) +b_search(SCR *sp, MARK *fm, MARK *rm, CHAR_T *ptrn, size_t plen, + CHAR_T **eptrn, u_int flags) { busy_t btype; recno_t lno; @@ -454,9 +433,7 @@ err: if (LF_ISSET(SEARCH_MSG)) * Display one of the search messages. */ static void -search_msg( - SCR *sp, - smsg_t msg) +search_msg(SCR *sp, smsg_t msg) { switch (msg) { case S_EMPTY: @@ -491,9 +468,7 @@ search_msg( * PUBLIC: void search_busy(SCR *, busy_t); */ void -search_busy( - SCR *sp, - busy_t btype) +search_busy(SCR *sp, busy_t btype) { sp->gp->scr_busy(sp, "078|Searching...", btype); } diff --git a/common/seq.c b/common/seq.c index 61c7fcd0b285..87bc051e1af9 100644 --- a/common/seq.c +++ b/common/seq.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: seq.c,v 10.18 2011/12/11 23:13:00 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -35,16 +31,8 @@ static const char sccsid[] = "$Id: seq.c,v 10.18 2011/12/11 23:13:00 zy Exp $"; * PUBLIC: size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int); */ int -seq_set( - SCR *sp, - CHAR_T *name, - size_t nlen, - CHAR_T *input, - size_t ilen, - CHAR_T *output, - size_t olen, - seq_t stype, - int flags) +seq_set(SCR *sp, CHAR_T *name, size_t nlen, CHAR_T *input, size_t ilen, + CHAR_T *output, size_t olen, seq_t stype, int flags) { CHAR_T *p; SEQ *lastqp, *qp; @@ -68,15 +56,14 @@ seq_set( sv_errno = errno; goto mem1; } - if (qp->output != NULL) - free(qp->output); + free(qp->output); qp->olen = olen; qp->output = p; return (0); } /* Allocate and initialize SEQ structure. */ - CALLOC(sp, qp, SEQ *, 1, sizeof(SEQ)); + CALLOC(sp, qp, 1, sizeof(SEQ)); if (qp == NULL) { sv_errno = errno; goto mem1; @@ -105,8 +92,7 @@ seq_set( } else if ((qp->output = v_wstrdup(sp, output, olen)) == NULL) { sv_errno = errno; free(qp->input); -mem3: if (qp->name != NULL) - free(qp->name); +mem3: free(qp->name); mem2: free(qp); mem1: errno = sv_errno; msgq(sp, M_SYSERR, NULL); @@ -139,11 +125,7 @@ mem1: errno = sv_errno; * PUBLIC: int seq_delete(SCR *, CHAR_T *, size_t, seq_t); */ int -seq_delete( - SCR *sp, - CHAR_T *input, - size_t ilen, - seq_t stype) +seq_delete(SCR *sp, CHAR_T *input, size_t ilen, seq_t stype) { SEQ *qp, *pre_qp = NULL; int diff; @@ -177,12 +159,9 @@ seq_delete( int seq_free(SEQ *qp) { - if (qp->name != NULL) - free(qp->name); - if (qp->input != NULL) - free(qp->input); - if (qp->output != NULL) - free(qp->output); + free(qp->name); + free(qp->input); + free(qp->output); free(qp); return (0); } @@ -196,14 +175,8 @@ seq_free(SEQ *qp) * PUBLIC: (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *); */ SEQ * -seq_find( - SCR *sp, - SEQ **lastqp, - EVENT *e_input, - CHAR_T *c_input, - size_t ilen, - seq_t stype, - int *ispartialp) +seq_find(SCR *sp, SEQ **lastqp, EVENT *e_input, CHAR_T *c_input, size_t ilen, + seq_t stype, int *ispartialp) { SEQ *lqp = NULL, *qp; int diff; @@ -298,10 +271,7 @@ seq_close(GS *gp) * PUBLIC: int seq_dump(SCR *, seq_t, int); */ int -seq_dump( - SCR *sp, - seq_t stype, - int isname) +seq_dump(SCR *sp, seq_t stype, int isname) { CHAR_T *p; GS *gp; @@ -346,11 +316,7 @@ seq_dump( * PUBLIC: int seq_save(SCR *, FILE *, char *, seq_t); */ int -seq_save( - SCR *sp, - FILE *fp, - char *prefix, - seq_t stype) +seq_save(SCR *sp, FILE *fp, char *prefix, seq_t stype) { CHAR_T *p; SEQ *qp; @@ -392,10 +358,7 @@ seq_save( * PUBLIC: int e_memcmp(CHAR_T *, EVENT *, size_t); */ int -e_memcmp( - CHAR_T *p1, - EVENT *ep, - size_t n) +e_memcmp(CHAR_T *p1, EVENT *ep, size_t n) { if (n != 0) { do { diff --git a/common/seq.h b/common/seq.h index 2c5ae576e3ee..514d5500b652 100644 --- a/common/seq.h +++ b/common/seq.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: seq.h,v 10.4 2011/12/11 21:43:39 zy Exp $ */ /* diff --git a/common/util.c b/common/util.c index 44c8e29482e6..1e87c6293550 100644 --- a/common/util.c +++ b/common/util.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: util.c,v 10.30 2013/03/19 10:00:27 yamt Exp $"; -#endif /* not lint */ - #include #include @@ -42,11 +38,8 @@ static const char sccsid[] = "$Id: util.c,v 10.30 2013/03/19 10:00:27 yamt Exp $ * PUBLIC: void *binc(SCR *, void *, size_t *, size_t); */ void * -binc( - SCR *sp, /* sp MAY BE NULL!!! */ - void *bp, - size_t *bsizep, - size_t min) +binc(SCR *sp, /* sp MAY BE NULL!!! */ + void *bp, size_t *bsizep, size_t min) { size_t csize; @@ -79,10 +72,7 @@ binc( * PUBLIC: int nonblank(SCR *, recno_t, size_t *); */ int -nonblank( - SCR *sp, - recno_t lno, - size_t *cnop) +nonblank(SCR *sp, recno_t lno, size_t *cnop) { CHAR_T *p; size_t cnt, len, off; @@ -108,22 +98,6 @@ nonblank( return (0); } -/* - * tail -- - * Return tail of a path. - * - * PUBLIC: char *tail(char *); - */ -char * -tail(char *path) -{ - char *p; - - if ((p = strrchr(path, '/')) == NULL) - return (path); - return (p + 1); -} - /* * join -- * Join two paths; need free. @@ -131,9 +105,7 @@ tail(char *path) * PUBLIC: char *join(char *, char *); */ char * -join( - char *path1, - char *path2) +join(char *path1, char *path2) { char *p; @@ -212,8 +184,8 @@ quote(char *str) n++; if (unsafe) continue; - if (isascii(*p)) { - if (isalnum(*p)) + if (isascii((u_char)*p)) { + if (isalnum((u_char)*p)) continue; switch (*p) { case '%': case '+': case ',': case '-': case '.': @@ -248,14 +220,11 @@ quote(char *str) * PUBLIC: char *v_strdup(SCR *, const char *, size_t); */ char * -v_strdup( - SCR *sp, - const char *str, - size_t len) +v_strdup(SCR *sp, const char *str, size_t len) { char *copy; - MALLOC(sp, copy, char *, len + 1); + MALLOC(sp, copy, len + 1); if (copy == NULL) return (NULL); memcpy(copy, str, len); @@ -270,13 +239,11 @@ v_strdup( * PUBLIC: CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t); */ CHAR_T * -v_wstrdup(SCR *sp, - const CHAR_T *str, - size_t len) +v_wstrdup(SCR *sp, const CHAR_T *str, size_t len) { CHAR_T *copy; - MALLOC(sp, copy, CHAR_T *, (len + 1) * sizeof(CHAR_T)); + MALLOC(sp, copy, (len + 1) * sizeof(CHAR_T)); if (copy == NULL) return (NULL); MEMCPY(copy, str, len); @@ -291,11 +258,7 @@ v_wstrdup(SCR *sp, * PUBLIC: enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int); */ enum nresult -nget_uslong( - u_long *valp, - const CHAR_T *p, - CHAR_T **endp, - int base) +nget_uslong(u_long *valp, const CHAR_T *p, CHAR_T **endp, int base) { errno = 0; *valp = STRTOUL(p, endp, base); @@ -313,11 +276,7 @@ nget_uslong( * PUBLIC: enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int); */ enum nresult -nget_slong( - long *valp, - const CHAR_T *p, - CHAR_T **endp, - int base) +nget_slong(long *valp, const CHAR_T *p, CHAR_T **endp, int base) { errno = 0; *valp = STRTOL(p, endp, base); @@ -339,8 +298,7 @@ nget_slong( * PUBLIC: void timepoint_steady(struct timespec *); */ void -timepoint_steady( - struct timespec *ts) +timepoint_steady(struct timespec *ts) { #ifdef __APPLE__ static mach_timebase_info_data_t base = { 0 }; @@ -370,8 +328,7 @@ timepoint_steady( * PUBLIC: void timepoint_system(struct timespec *); */ void -timepoint_system( - struct timespec *ts) +timepoint_system(struct timespec *ts) { #ifdef __APPLE__ clock_serv_t clk; @@ -404,10 +361,7 @@ timepoint_system( * PUBLIC: void TRACE(SCR *, const char *, ...); */ void -TRACE( - SCR *sp, - const char *fmt, - ...) +TRACE(SCR *sp, const char *fmt, ...) { FILE *tfp; va_list ap; diff --git a/common/util.h b/common/util.h index e6b2bec94e15..46fa4a17bc0f 100644 --- a/common/util.h +++ b/common/util.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: util.h,v 10.7 2013/02/24 21:00:10 zy Exp $ */ /* Macros to init/set/clear/test flags. */ diff --git a/docs/man/Makefile b/docs/man/Makefile deleted file mode 100644 index 54338646791f..000000000000 --- a/docs/man/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# @(#)Makefile 8.7 (Berkeley) 8/18/96 - -ROFF= groff - -all: vi.0 vi.0.ps - -vi.0: vi.1 - ${ROFF} -man -Tascii < vi.1 > $@ - chmod 444 $@ - -vi.0.ps: vi.1 - ${ROFF} -man < vi.1 > $@ - chmod 444 $@ - -clean: - rm -f vi.0 vi.0.ps diff --git a/ex/ex.c b/ex/ex.c index 00df2cc65f80..c93d49717b22 100644 --- a/ex/ex.c +++ b/ex/ex.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex.c,v 10.80 2012/10/03 16:24:40 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -388,7 +384,7 @@ loop: ecp = SLIST_FIRST(gp->ecq); } else { for (p = ecp->cp; ecp->clen > 0; --ecp->clen, ++ecp->cp) - if (!isascii(*ecp->cp) || !isalpha(*ecp->cp)) + if (!isazAZ(*ecp->cp)) break; if ((namelen = ecp->cp - p) == 0) { msgq(sp, M_ERR, "080|Unknown command name"); @@ -732,8 +728,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI)) if (!cmdskip(ecp->cp[0])) break; - if (!isascii(ecp->cp[0]) || - isalnum(ecp->cp[0]) || ecp->cp[0] == '|') { + if (is09azAZ(ecp->cp[0]) || ecp->cp[0] == '|') { ecp->rcmd = cmds[C_SUBSTITUTE]; ecp->rcmd.fn = ex_subagain; ecp->cmd = &ecp->rcmd; @@ -1504,7 +1499,7 @@ usage: msgq(sp, M_ERR, "086|Usage: %s", ecp->cmd->usage); ecp->save_cmd -= arg1_len; ecp->save_cmdlen += arg1_len; - MEMCPY(ecp->save_cmd, arg1, arg1_len); + MEMMOVE(ecp->save_cmd, arg1, arg1_len); /* * Any commands executed from a +cmd are executed starting at diff --git a/ex/ex.h b/ex/ex.h index 4cb52ccb3545..5ccf7c6c362b 100644 --- a/ex/ex.h +++ b/ex/ex.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: ex.h,v 10.31 2012/10/03 02:33:24 zy Exp $ */ #define PROMPTCHAR ':' /* Prompt using a colon. */ diff --git a/ex/ex_abbrev.c b/ex/ex_abbrev.c index 5fd5735d1df8..9fd477874239 100644 --- a/ex/ex_abbrev.c +++ b/ex/ex_abbrev.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_abbrev.c,v 10.10 2001/12/16 18:18:54 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_append.c b/ex/ex_append.c index d2d44e288912..5b9a1697e974 100644 --- a/ex/ex_append.c +++ b/ex/ex_append.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_append.c,v 10.34 2001/06/25 15:19:14 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_args.c b/ex/ex_args.c index 37dfa88bd487..5e8f2d23f573 100644 --- a/ex/ex_args.c +++ b/ex/ex_args.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_args.c,v 10.19 2011/12/16 16:18:10 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -88,8 +84,7 @@ ex_next(SCR *sp, EXCMD *cmdp) sp->cargv = NULL; /* Create a new list. */ - CALLOC_RET(sp, - sp->argv, char **, cmdp->argc + 1, sizeof(char *)); + CALLOC_RET(sp, sp->argv, cmdp->argc + 1, sizeof(char *)); for (ap = sp->argv, argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) { INT2CHAR(sp, argv[0]->bp, argv[0]->len, np, nlen); @@ -311,7 +306,7 @@ ex_buildargv(SCR *sp, EXCMD *cmdp, char *name) size_t nlen; argc = cmdp == NULL ? 1 : cmdp->argc; - CALLOC(sp, s_argv, char **, argc + 1, sizeof(char *)); + CALLOC(sp, s_argv, argc + 1, sizeof(char *)); if ((ap = s_argv) == NULL) return (NULL); diff --git a/ex/ex_argv.c b/ex/ex_argv.c index 2d121cb5e560..d6f9a8bb8aa5 100644 --- a/ex/ex_argv.c +++ b/ex/ex_argv.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_argv.c,v 11.2 2012/10/09 23:00:29 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -484,7 +480,7 @@ argv_alloc(SCR *sp, size_t len) /* First argument. */ if (exp->args[off] == NULL) { - CALLOC(sp, exp->args[off], ARGS *, 1, sizeof(ARGS)); + CALLOC(sp, exp->args[off], 1, sizeof(ARGS)); if (exp->args[off] == NULL) goto mem; } @@ -507,7 +503,7 @@ mem: msgq(sp, M_SYSERR, NULL); /* Second argument. */ if (exp->args[++off] == NULL) { - CALLOC(sp, exp->args[off], ARGS *, 1, sizeof(ARGS)); + CALLOC(sp, exp->args[off], 1, sizeof(ARGS)); if (exp->args[off] == NULL) goto mem; } diff --git a/ex/ex_at.c b/ex/ex_at.c index 875423f81ec3..48c708026e78 100644 --- a/ex/ex_at.c +++ b/ex/ex_at.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_at.c,v 10.16 2001/06/25 15:19:14 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -82,9 +78,9 @@ ex_at(SCR *sp, EXCMD *cmdp) * the range, continue to execute after a file/screen switch, which * means @ buffers are still useful in a multi-screen environment. */ - CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD)); + CALLOC_RET(sp, ecp, 1, sizeof(EXCMD)); TAILQ_INIT(ecp->rq); - CALLOC_RET(sp, rp, RANGE *, 1, sizeof(RANGE)); + CALLOC_RET(sp, rp, 1, sizeof(RANGE)); rp->start = cmdp->addr1.lno; if (F_ISSET(cmdp, E_ADDR_DEF)) { rp->stop = rp->start; @@ -106,7 +102,7 @@ ex_at(SCR *sp, EXCMD *cmdp) TAILQ_FOREACH_REVERSE(tp, cbp->textq, _texth, q) len += tp->len + 1; - MALLOC_RET(sp, ecp->cp, CHAR_T *, len * 2 * sizeof(CHAR_T)); + MALLOC_RET(sp, ecp->cp, len * 2 * sizeof(CHAR_T)); ecp->o_cp = ecp->cp; ecp->o_clen = len; ecp->cp[len] = '\0'; diff --git a/ex/ex_bang.c b/ex/ex_bang.c index 9b7c3766ec70..ff2b39bbff9a 100644 --- a/ex/ex_bang.c +++ b/ex/ex_bang.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_bang.c,v 10.36 2001/06/25 15:19:14 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -67,8 +63,7 @@ ex_bang(SCR *sp, EXCMD *cmdp) /* Set the "last bang command" remembered value. */ exp = EXP(sp); - if (exp->lastbcomm != NULL) - free(exp->lastbcomm); + free(exp->lastbcomm); if ((exp->lastbcomm = v_wstrdup(sp, ap->bp, ap->len)) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); @@ -178,6 +173,10 @@ ex_bang(SCR *sp, EXCMD *cmdp) if (!F_ISSET(sp, SC_VI) && !F_ISSET(sp, SC_EX_SILENT)) (void)ex_puts(sp, "!\n"); + /* Apply expandtab to the new text */ + if (O_ISSET(sp, O_EXPANDTAB)) + ex_retab(sp, cmdp); + /* * XXX * The ! commands never return an error, so that autoprint always diff --git a/ex/ex_cd.c b/ex/ex_cd.c index 4b3216635ef9..d97012a94473 100644 --- a/ex/ex_cd.c +++ b/ex/ex_cd.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_cd.c,v 10.13 2012/04/12 06:28:27 zy Exp $"; -#endif /* not lint */ - #include #include diff --git a/ex/ex_cmd.c b/ex/ex_cmd.c index 87e32d2a4cf5..9ce29ff697af 100644 --- a/ex/ex_cmd.c +++ b/ex/ex_cmd.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_cmd.c,v 10.26 2011/07/14 15:11:16 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_cscope.c b/ex/ex_cscope.c index 0503fb315162..629861d55680 100644 --- a/ex/ex_cscope.c +++ b/ex/ex_cscope.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_cscope.c,v 10.25 2012/10/04 09:23:03 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -261,7 +257,7 @@ cscope_add(SCR *sp, EXCMD *cmdp, CHAR_T *dname) /* Allocate a cscope connection structure and initialize its fields. */ len = strlen(np); - CALLOC_RET(sp, csc, CSC *, 1, sizeof(CSC) + len); + CALLOC_RET(sp, csc, 1, sizeof(CSC) + len); csc->dname = csc->buf; csc->dlen = len; memcpy(csc->dname, np, len); @@ -321,7 +317,7 @@ get_paths(SCR *sp, CSC *csc) if (stat(buf, &sb) == 0) { /* Read in the CSCOPE_PATHS file. */ len = sb.st_size; - MALLOC_RET(sp, csc->pbuf, char *, len + 1); + MALLOC_RET(sp, csc->pbuf, len + 1); if ((fd = open(buf, O_RDONLY, 0)) < 0 || read(fd, csc->pbuf, len) != len) { msgq_str(sp, M_SYSERR, buf, "%s"); @@ -340,8 +336,7 @@ get_paths(SCR *sp, CSC *csc) ++nentries; /* Build an array of pointers to the paths. */ - CALLOC_GOTO(sp, - csc->paths, char **, nentries + 1, sizeof(char **)); + CALLOC_GOTO(sp, csc->paths, nentries + 1, sizeof(char **)); for (pathp = csc->paths, p = strtok(csc->pbuf, ":"); p != NULL; p = strtok(NULL, ":")) *pathp++ = p; @@ -357,15 +352,13 @@ get_paths(SCR *sp, CSC *csc) msgq(sp, M_SYSERR, NULL); return (1); } - CALLOC_GOTO(sp, csc->paths, char **, 2, sizeof(char *)); + CALLOC_GOTO(sp, csc->paths, 2, sizeof(char *)); csc->paths[0] = csc->pbuf; return (0); alloc_err: - if (csc->pbuf != NULL) { - free(csc->pbuf); - csc->pbuf = NULL; - } + free(csc->pbuf); + csc->pbuf = NULL; return (1); } @@ -483,11 +476,11 @@ cscope_find(SCR *sp, EXCMD *cmdp, CHAR_T *pattern) rtqp = NULL; if (TAILQ_EMPTY(exp->tq)) { /* Initialize the `local context' tag queue structure. */ - CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ)); + CALLOC_GOTO(sp, rtqp, 1, sizeof(TAGQ)); TAILQ_INIT(rtqp->tagq); /* Initialize and link in its tag structure. */ - CALLOC_GOTO(sp, rtp, TAG *, 1, sizeof(TAG)); + CALLOC_GOTO(sp, rtp, 1, sizeof(TAG)); TAILQ_INSERT_HEAD(rtqp->tagq, rtp, q); rtqp->current = rtp; } @@ -497,8 +490,8 @@ cscope_find(SCR *sp, EXCMD *cmdp, CHAR_T *pattern) np = strdup(np); if ((tqp = create_cs_cmd(sp, np, &search)) == NULL) goto err; - if (np != NULL) - free(np); + free(np); + np = NULL; /* * Stick the current context in a convenient place, we'll lose it @@ -529,10 +522,8 @@ cscope_find(SCR *sp, EXCMD *cmdp, CHAR_T *pattern) if (matches == 0) { msgq(sp, M_INFO, "278|No matches for query"); -nomatch: if (rtp != NULL) - free(rtp); - if (rtqp != NULL) - free(rtqp); +nomatch: free(rtp); + free(rtqp); tagq_free(sp, tqp); return (1); } @@ -588,12 +579,9 @@ nomatch: if (rtp != NULL) err: alloc_err: - if (rtqp != NULL) - free(rtqp); - if (rtp != NULL) - free(rtp); - if (np != NULL) - free(np); + free(rtqp); + free(rtp); + free(np); return (1); } @@ -652,7 +640,7 @@ usage: (void)csc_help(sp, "find"); tlen = strlen(p); /* Allocate and initialize the TAGQ structure. */ - CALLOC(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + tlen + 3); + CALLOC(sp, tqp, 1, sizeof(TAGQ) + tlen + 3); if (tqp == NULL) return (NULL); TAILQ_INIT(tqp->tagq); @@ -756,9 +744,8 @@ parse(SCR *sp, CSC *csc, TAGQ *tqp, int *matchesp) * Allocate and initialize a tag structure plus the variable * length cscope information that follows it. */ - CALLOC_RET(sp, tp, - TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 + - (slen + 1) * sizeof(CHAR_T)); + CALLOC_RET(sp, tp, 1, + sizeof(TAG) + dlen + 2 + nlen + 1 + (slen + 1) * sizeof(CHAR_T)); tp->fname = (char *)tp->buf; if (dlen == 1 && *dname == '.') --dlen; @@ -770,9 +757,11 @@ parse(SCR *sp, CSC *csc, TAGQ *tqp, int *matchesp) memcpy(tp->fname + dlen, name, nlen + 1); tp->fnlen = dlen + nlen; tp->slno = slno; - tp->search = (CHAR_T*)(tp->fname + tp->fnlen + 1); - CHAR2INT(sp, search, slen + 1, wp, wlen); - MEMCPY(tp->search, wp, (tp->slen = slen) + 1); + if (slen != 0) { + tp->search = (CHAR_T*)(tp->fname + tp->fnlen + 1); + CHAR2INT(sp, search, slen + 1, wp, wlen); + MEMCPY(tp->search, wp, (tp->slen = slen) + 1); + } TAILQ_INSERT_TAIL(tqp->tagq, tp, q); /* Try to preset the tag within the current file. */ @@ -943,10 +932,8 @@ badno: msgq(sp, M_ERR, "312|%d: no such cscope session", n); (void)waitpid(csc->pid, &pstat, 0); /* Discard cscope connection information. */ - if (csc->pbuf != NULL) - free(csc->pbuf); - if (csc->paths != NULL) - free(csc->paths); + free(csc->pbuf); + free(csc->paths); free(csc); return (0); } diff --git a/ex/ex_def.h b/ex/ex_def.h deleted file mode 100644 index 7afb7b19d677..000000000000 --- a/ex/ex_def.h +++ /dev/null @@ -1,76 +0,0 @@ -#define C_SCROLL 0 -#define C_BANG 1 -#define C_HASH 2 -#define C_SUBAGAIN 3 -#define C_STAR 4 -#define C_SHIFTL 5 -#define C_EQUAL 6 -#define C_SHIFTR 7 -#define C_AT 8 -#define C_APPEND 9 -#define C_ABBR 10 -#define C_ARGS 11 -#define C_BG 12 -#define C_CHANGE 13 -#define C_CD 14 -#define C_CHDIR 15 -#define C_COPY 16 -#define C_CSCOPE 17 -#define C_DELETE 18 -#define C_DISPLAY 19 -#define C_EDIT 20 -#define C_EX 21 -#define C_EXUSAGE 22 -#define C_FILE 23 -#define C_FG 24 -#define C_GLOBAL 25 -#define C_HELP 26 -#define C_INSERT 27 -#define C_JOIN 28 -#define C_K 29 -#define C_LIST 30 -#define C_MOVE 31 -#define C_MARK 32 -#define C_MAP 33 -#define C_MKEXRC 34 -#define C_NEXT 35 -#define C_NUMBER 36 -#define C_OPEN 37 -#define C_PRINT 38 -#define C_PRESERVE 39 -#define C_PREVIOUS 40 -#define C_PUT 41 -#define C_QUIT 42 -#define C_READ 43 -#define C_RECOVER 44 -#define C_RESIZE 45 -#define C_REWIND 46 -#define C_SUBSTITUTE 47 -#define C_SCRIPT 48 -#define C_SET 49 -#define C_SHELL 50 -#define C_SOURCE 51 -#define C_STOP 52 -#define C_SUSPEND 53 -#define C_T 54 -#define C_TAG 55 -#define C_TAGNEXT 56 -#define C_TAGPOP 57 -#define C_TAGPREV 58 -#define C_TAGTOP 59 -#define C_UNDO 60 -#define C_UNABBREVIATE 61 -#define C_UNMAP 62 -#define C_V 63 -#define C_VERSION 64 -#define C_VISUAL_EX 65 -#define C_VISUAL_VI 66 -#define C_VIUSAGE 67 -#define C_VSPLIT 68 -#define C_WRITE 69 -#define C_WN 70 -#define C_WQ 71 -#define C_XIT 72 -#define C_YANK 73 -#define C_Z 74 -#define C_SUBTILDE 75 diff --git a/ex/ex_delete.c b/ex/ex_delete.c index e59948981560..2017ed7f41b9 100644 --- a/ex/ex_delete.c +++ b/ex/ex_delete.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_delete.c,v 10.11 2001/06/25 15:19:15 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_display.c b/ex/ex_display.c index 0ace60bb3029..2ca62fce1ec7 100644 --- a/ex/ex_display.c +++ b/ex/ex_display.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_display.c,v 10.15 2001/06/25 15:19:15 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_edit.c b/ex/ex_edit.c index f9f77e813988..4d3a1d2856c8 100644 --- a/ex/ex_edit.c +++ b/ex/ex_edit.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_edit.c,v 10.15 2011/12/22 23:26:50 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_equal.c b/ex/ex_equal.c index a6745ce05bee..d9ceaf95efbe 100644 --- a/ex/ex_equal.c +++ b/ex/ex_equal.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_equal.c,v 10.12 2001/06/25 15:19:15 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_file.c b/ex/ex_file.c index fdef2112f118..c06ac6e493a6 100644 --- a/ex/ex_file.c +++ b/ex/ex_file.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_file.c,v 10.14 2001/06/25 15:19:16 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_filter.c b/ex/ex_filter.c index cff55bfc5bf2..cd04643b5f08 100644 --- a/ex/ex_filter.c +++ b/ex/ex_filter.c @@ -9,12 +9,9 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_filter.c,v 10.44 2003/11/05 17:11:54 skimo Exp $"; -#endif /* not lint */ - #include #include +#include #include #include diff --git a/ex/ex_global.c b/ex/ex_global.c index 4482ccd32ad9..54c6411d8799 100644 --- a/ex/ex_global.c +++ b/ex/ex_global.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_global.c,v 10.32 2011/12/26 23:37:01 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -91,7 +87,7 @@ ex_g_setup(SCR *sp, EXCMD *cmdp, enum which cmd) if (cmdp->argc == 0) goto usage; for (p = cmdp->argv[0]->bp; cmdskip(*p); ++p); - if (!isascii(*p) || *p == '\0' || isalnum(*p) || + if (*p == '\0' || is09azAZ(*p) || *p == '\\' || *p == '|' || *p == '\n') { usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); return (1); @@ -157,7 +153,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); return (1); /* Get an EXCMD structure. */ - CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD)); + CALLOC_RET(sp, ecp, 1, sizeof(EXCMD)); TAILQ_INIT(ecp->rq); /* @@ -172,7 +168,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); len = 1; } - MALLOC_RET(sp, ecp->cp, CHAR_T *, (len * 2) * sizeof(CHAR_T)); + MALLOC_RET(sp, ecp->cp, (len * 2) * sizeof(CHAR_T)); ecp->o_cp = ecp->cp; ecp->o_clen = len; MEMCPY(ecp->cp + len, p, len); @@ -234,7 +230,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); } /* Allocate a new range, and append it to the list. */ - CALLOC(sp, rp, RANGE *, 1, sizeof(RANGE)); + CALLOC(sp, rp, 1, sizeof(RANGE)); if (rp == NULL) return (1); rp->start = rp->stop = start; @@ -298,7 +294,7 @@ ex_g_insdel(SCR *sp, lnop_t op, recno_t lno) free(rp); } } else { - CALLOC_RET(sp, nrp, RANGE *, 1, sizeof(RANGE)); + CALLOC_RET(sp, nrp, 1, sizeof(RANGE)); nrp->start = lno + 1; nrp->stop = rp->stop + 1; rp->stop = lno - 1; diff --git a/ex/ex_init.c b/ex/ex_init.c index ad54591a2395..96bc5d82ffa8 100644 --- a/ex/ex_init.c +++ b/ex/ex_init.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_init.c,v 10.33 2012/04/11 19:12:34 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -46,7 +42,7 @@ ex_screen_copy(SCR *orig, SCR *sp) EX_PRIVATE *oexp, *nexp; /* Create the private ex structure. */ - CALLOC_RET(orig, nexp, EX_PRIVATE *, 1, sizeof(EX_PRIVATE)); + CALLOC_RET(orig, nexp, 1, sizeof(EX_PRIVATE)); sp->ex_private = nexp; /* Initialize queues. */ @@ -94,14 +90,11 @@ ex_screen_end(SCR *sp) if (argv_free(sp)) rval = 1; - if (exp->ibp != NULL) - free(exp->ibp); + free(exp->ibp); - if (exp->lastbcomm != NULL) - free(exp->lastbcomm); + free(exp->lastbcomm); - if (exp->ibcw.bp1.c != NULL) - free(exp->ibcw.bp1.c); + free(exp->ibcw.bp1.c); if (ex_tag_free(sp)) rval = 1; @@ -291,7 +284,7 @@ ex_run_str(SCR *sp, char *name, CHAR_T *str, size_t len, int ex_flags, int nocop gp = sp->gp; if (EXCMD_RUNNING(gp)) { - CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD)); + CALLOC_RET(sp, ecp, 1, sizeof(EXCMD)); SLIST_INSERT_HEAD(gp->ecq, ecp, q); } else ecp = &gp->excmd; diff --git a/ex/ex_join.c b/ex/ex_join.c index 2917b2e2d8ab..c74dcd85c0b2 100644 --- a/ex/ex_join.c +++ b/ex/ex_join.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_join.c,v 10.17 2004/03/16 14:14:04 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_map.c b/ex/ex_map.c index 932d63385d50..cdfae94f493d 100644 --- a/ex/ex_map.c +++ b/ex/ex_map.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_map.c,v 10.11 2001/06/25 15:19:17 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_mark.c b/ex/ex_mark.c index e259837d5d1e..bd3e33bd0f22 100644 --- a/ex/ex_mark.c +++ b/ex/ex_mark.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_mark.c,v 10.9 2001/06/25 15:19:17 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_mkexrc.c b/ex/ex_mkexrc.c index 82678b14878e..dc6a07210fd1 100644 --- a/ex/ex_mkexrc.c +++ b/ex/ex_mkexrc.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_mkexrc.c,v 10.13 2001/06/25 15:19:17 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_move.c b/ex/ex_move.c index a7f6b5fb87f1..d910a7530f81 100644 --- a/ex/ex_move.c +++ b/ex/ex_move.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_move.c,v 10.16 2012/02/11 15:52:33 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_open.c b/ex/ex_open.c index ca54eca08f6d..5853ac5996a5 100644 --- a/ex/ex_open.c +++ b/ex/ex_open.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_open.c,v 10.8 2001/06/25 15:19:17 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_preserve.c b/ex/ex_preserve.c index e0dc286f82c5..bbd30bb9dbe5 100644 --- a/ex/ex_preserve.c +++ b/ex/ex_preserve.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_preserve.c,v 10.15 2001/06/25 15:19:18 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_print.c b/ex/ex_print.c index 7cdde7a38a25..da541977672c 100644 --- a/ex/ex_print.c +++ b/ex/ex_print.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_print.c,v 10.26 2013/11/02 02:11:07 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -213,7 +209,7 @@ ex_prchars(SCR *sp, const CHAR_T *p, size_t *colp, size_t len, gp = sp->gp; ts = O_VAL(sp, O_TABSTOP); for (col = *colp; len--;) - if ((ch = *p++) == L('\t') && !LF_ISSET(E_C_LIST)) + if ((ch = *p++) == '\t' && !LF_ISSET(E_C_LIST)) for (tlen = ts - col % ts; col < sp->cols && tlen--; ++col) { (void)ex_printf(sp, diff --git a/ex/ex_put.c b/ex/ex_put.c index 384b500f4709..c45fc551bfd1 100644 --- a/ex/ex_put.c +++ b/ex/ex_put.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_put.c,v 10.8 2001/06/25 15:19:18 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_quit.c b/ex/ex_quit.c index faf31d71d953..8f0f8112727d 100644 --- a/ex/ex_quit.c +++ b/ex/ex_quit.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_quit.c,v 10.8 2001/06/25 15:19:18 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_read.c b/ex/ex_read.c index 00276a270cd3..cd307c322eaf 100644 --- a/ex/ex_read.c +++ b/ex/ex_read.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_read.c,v 10.44 2001/06/25 15:19:19 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -112,8 +108,7 @@ ex_read(SCR *sp, EXCMD *cmdp) /* Set the last bang command. */ exp = EXP(sp); - if (exp->lastbcomm != NULL) - free(exp->lastbcomm); + free(exp->lastbcomm); if ((exp->lastbcomm = v_wstrdup(sp, cmdp->argv[argc]->bp, cmdp->argv[argc]->len)) == NULL) { diff --git a/ex/ex_screen.c b/ex/ex_screen.c index 7bec2bc9ab12..12bfdc3ef161 100644 --- a/ex/ex_screen.c +++ b/ex/ex_screen.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_screen.c,v 10.12 2001/06/25 15:19:19 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_script.c b/ex/ex_script.c index 2dc44658a62d..5ba8c028f81a 100644 --- a/ex/ex_script.c +++ b/ex/ex_script.c @@ -12,10 +12,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_script.c,v 10.44 2012/10/05 10:17:47 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -93,7 +89,7 @@ sscr_init(SCR *sp) if (opts_empty(sp, O_SHELL, 0)) return (1); - MALLOC_RET(sp, sc, SCRIPT *, sizeof(SCRIPT)); + MALLOC_RET(sp, sc, sizeof(SCRIPT)); sp->script = sc; sc->sh_prompt = NULL; sc->sh_prompt_len = 0; @@ -523,9 +519,8 @@ sscr_setprompt(SCR *sp, char *buf, size_t len) SCRIPT *sc; sc = sp->script; - if (sc->sh_prompt) - free(sc->sh_prompt); - MALLOC(sp, sc->sh_prompt, char *, len + 1); + free(sc->sh_prompt); + MALLOC(sp, sc->sh_prompt, len + 1); if (sc->sh_prompt == NULL) { sscr_end(sp); return (1); diff --git a/ex/ex_set.c b/ex/ex_set.c index 2acc3a887221..e1a674edce78 100644 --- a/ex/ex_set.c +++ b/ex/ex_set.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_set.c,v 10.8 2001/06/25 15:19:19 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_shell.c b/ex/ex_shell.c index 43be5cb21756..7b483fd4e14c 100644 --- a/ex/ex_shell.c +++ b/ex/ex_shell.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_shell.c,v 10.44 2012/07/06 06:51:26 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_shift.c b/ex/ex_shift.c index fec800ca7ded..97c7840a9a02 100644 --- a/ex/ex_shift.c +++ b/ex/ex_shift.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_shift.c,v 10.17 2001/06/25 15:19:20 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -25,7 +21,7 @@ static const char sccsid[] = "$Id: ex_shift.c,v 10.17 2001/06/25 15:19:20 skimo #include "../common/common.h" -enum which {LEFT, RIGHT}; +enum which {RETAB, LEFT, RIGHT}; static int shift(SCR *, EXCMD *, enum which); /* @@ -51,6 +47,18 @@ ex_shiftr(SCR *sp, EXCMD *cmdp) return (shift(sp, cmdp, RIGHT)); } +/* + * ex_retab -- Expand tabs (if enabled) + * + * + * PUBLIC: int ex_retab(SCR *, EXCMD *); + */ +int +ex_retab(SCR *sp, EXCMD *cmdp) +{ + return (shift(sp, cmdp, RETAB)); +} + /* * shift -- * Ex shift support. @@ -114,7 +122,9 @@ shift(SCR *sp, EXCMD *cmdp, enum which rl) break; /* Calculate the new indent amount. */ - if (rl == RIGHT) + if (rl == RETAB) + newcol = oldcol; + else if (rl == RIGHT) newcol = oldcol + sw; else { newcol = oldcol < sw ? 0 : oldcol - sw; @@ -132,10 +142,13 @@ shift(SCR *sp, EXCMD *cmdp, enum which rl) * Build a new indent string and count the number of * characters it uses. */ - for (tbp = bp, newidx = 0; - newcol >= O_VAL(sp, O_TABSTOP); ++newidx) { - *tbp++ = '\t'; - newcol -= O_VAL(sp, O_TABSTOP); + tbp = bp; + newidx = 0; + if (!O_ISSET(sp, O_EXPANDTAB)) { + for (; newcol >= O_VAL(sp, O_TABSTOP); ++newidx) { + *tbp++ = '\t'; + newcol -= O_VAL(sp, O_TABSTOP); + } } for (; newcol > 0; --newcol, ++newidx) *tbp++ = ' '; diff --git a/ex/ex_source.c b/ex/ex_source.c index 6ac698da512f..656c0d348007 100644 --- a/ex/ex_source.c +++ b/ex/ex_source.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_source.c,v 10.17 2011/12/19 16:17:06 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -65,7 +61,7 @@ ex_source(SCR *sp, EXCMD *cmdp) goto err; } - MALLOC(sp, bp, char *, (size_t)sb.st_size + 1); + MALLOC(sp, bp, (size_t)sb.st_size + 1); if (bp == NULL) { (void)close(fd); return (1); @@ -88,8 +84,7 @@ err: msgq_str(sp, M_SYSERR, name, "%s"); msgq(sp, M_ERR, "323|Invalid input. Truncated."); /* Put it on the ex queue. */ rc = ex_run_str(sp, np, wp, wlen - 1, 1, 0); - if (np != NULL) - free(np); + free(np); free(bp); return (rc); } diff --git a/ex/ex_stop.c b/ex/ex_stop.c index 4bc1bb2a5e2d..ff3f9c3867a4 100644 --- a/ex/ex_stop.c +++ b/ex/ex_stop.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_stop.c,v 10.11 2001/06/25 15:19:20 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_subst.c b/ex/ex_subst.c index db79376fcd32..d32d583f6a3b 100644 --- a/ex/ex_subst.c +++ b/ex/ex_subst.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_subst.c,v 10.53 2011/12/21 20:40:35 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -78,7 +74,7 @@ ex_s(SCR *sp, EXCMD *cmdp) subagain: return (ex_subagain(sp, cmdp)); delim = *p++; - if (!isascii(delim) || isalnum(delim) || delim == '\\') + if (is09azAZ(delim) || delim == '\\') return (s(sp, cmdp, p, &sp->subre_c, SUB_MUSTSETR)); /* @@ -190,8 +186,7 @@ subagain: return (ex_subagain(sp, cmdp)); if (p[0] == '\0' || p[0] == delim) { if (p[0] == delim) ++p; - if (sp->repl != NULL) - free(sp->repl); + free(sp->repl); sp->repl = NULL; sp->repl_len = 0; } else if (p[0] == '%' && (p[1] == '\0' || p[1] == delim)) @@ -230,9 +225,8 @@ tilde: ++p; ++len; } if ((sp->repl_len = len) != 0) { - if (sp->repl != NULL) - free(sp->repl); - MALLOC(sp, sp->repl, CHAR_T *, len * sizeof(CHAR_T)); + free(sp->repl); + MALLOC(sp, sp->repl, len * sizeof(CHAR_T)); if (sp->repl == NULL) { FREE_SPACEW(sp, bp, blen); return (1); @@ -870,8 +864,7 @@ err: rval = 1; if (bp != NULL) FREE_SPACEW(sp, bp, blen); - if (lb != NULL) - free(lb); + free(lb); return (rval); } @@ -940,10 +933,9 @@ re_compile(SCR *sp, CHAR_T *ptrn, size_t plen, CHAR_T **ptrnp, size_t *lenp, reg return (1); /* Discard previous pattern. */ - if (*ptrnp != NULL) { - free(*ptrnp); - *ptrnp = NULL; - } + free(*ptrnp); + *ptrnp = NULL; + if (lenp != NULL) *lenp = plen; @@ -954,7 +946,7 @@ re_compile(SCR *sp, CHAR_T *ptrn, size_t plen, CHAR_T **ptrnp, size_t *lenp, reg * Regcomp isn't 8-bit clean, so the pattern is nul-terminated * for now. There's just no other solution. */ - MALLOC(sp, *ptrnp, CHAR_T *, (plen + 1) * sizeof(CHAR_T)); + MALLOC(sp, *ptrnp, (plen + 1) * sizeof(CHAR_T)); if (*ptrnp != NULL) { MEMCPY(*ptrnp, ptrn, plen); (*ptrnp)[plen] = '\0'; @@ -1289,7 +1281,7 @@ re_error(SCR *sp, int errcode, regex_t *preg) char *oe; s = regerror(errcode, preg, "", 0); - MALLOC(sp, oe, char *, s); + MALLOC(sp, oe, s); if (oe != NULL) { (void)regerror(errcode, preg, oe, s); msgq(sp, M_ERR, "RE error: %s", oe); diff --git a/ex/ex_tag.c b/ex/ex_tag.c index 172e5e204d55..10cb4cde8f15 100644 --- a/ex/ex_tag.c +++ b/ex/ex_tag.c @@ -12,10 +12,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_tag.c,v 10.54 2012/04/12 07:17:30 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -98,8 +94,7 @@ ex_tag_push(SCR *sp, EXCMD *cmdp) exp = EXP(sp); switch (cmdp->argc) { case 1: - if (exp->tag_last != NULL) - free(exp->tag_last); + free(exp->tag_last); if ((exp->tag_last = v_wstrdup(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len)) == NULL) { @@ -590,12 +585,14 @@ tagf_copy(SCR *sp, TAGF *otfp, TAGF **tfpp) { TAGF *tfp; - MALLOC_RET(sp, tfp, TAGF *, sizeof(TAGF)); + MALLOC_RET(sp, tfp, sizeof(TAGF)); *tfp = *otfp; /* XXX: Allocate as part of the TAGF structure!!! */ - if ((tfp->name = strdup(otfp->name)) == NULL) + if ((tfp->name = strdup(otfp->name)) == NULL) { + free(tfp); return (1); + } *tfpp = tfp; return (0); @@ -614,7 +611,7 @@ tagq_copy(SCR *sp, TAGQ *otqp, TAGQ **tqpp) len = sizeof(TAGQ); if (otqp->tag != NULL) len += otqp->tlen + 1; - MALLOC_RET(sp, tqp, TAGQ *, len); + MALLOC_RET(sp, tqp, len); memcpy(tqp, otqp, len); TAILQ_INIT(tqp->tagq); @@ -643,7 +640,7 @@ tag_copy(SCR *sp, TAG *otp, TAG **tpp) len += otp->slen + 1; if (otp->msg != NULL) len += otp->mlen + 1; - MALLOC_RET(sp, tp, TAG *, len); + MALLOC_RET(sp, tp, len); memcpy(tp, otp, len); if (otp->fname != NULL) @@ -727,11 +724,11 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_screen, int force) rtqp = NULL; if (TAILQ_EMPTY(exp->tq)) { /* Initialize the `local context' tag queue structure. */ - CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ)); + CALLOC_GOTO(sp, rtqp, 1, sizeof(TAGQ)); TAILQ_INIT(rtqp->tagq); /* Initialize and link in its tag structure. */ - CALLOC_GOTO(sp, rtp, TAG *, 1, sizeof(TAG)); + CALLOC_GOTO(sp, rtp, 1, sizeof(TAG)); TAILQ_INSERT_HEAD(rtqp->tagq, rtp, q); rtqp->current = rtp; } @@ -802,10 +799,8 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_screen, int force) err: alloc_err: - if (rtqp != NULL) - free(rtqp); - if (rtp != NULL) - free(rtp); + free(rtqp); + free(rtp); tagq_free(sp, tqp); return (1); } @@ -858,8 +853,8 @@ ex_tagf_alloc(SCR *sp, char *str) for (p = t = str;; ++p) { if (*p == '\0' || cmdskip(*p)) { if ((len = p - t)) { - MALLOC_RET(sp, tfp, TAGF *, sizeof(TAGF)); - MALLOC(sp, tfp->name, char *, len + 1); + MALLOC_RET(sp, tfp, sizeof(TAGF)); + MALLOC(sp, tfp->name, len + 1); if (tfp->name == NULL) { free(tfp); return (1); @@ -896,8 +891,7 @@ ex_tag_free(SCR *sp) tagq_free(sp, tqp); while ((tfp = TAILQ_FIRST(exp->tagfq)) != NULL) tagf_free(sp, tfp); - if (exp->tag_last != NULL) - free(exp->tag_last); + free(exp->tag_last); return (0); } @@ -985,7 +979,7 @@ ctag_slist(SCR *sp, CHAR_T *tag) /* Allocate and initialize the tag queue structure. */ INT2CHAR(sp, tag, STRLEN(tag) + 1, np, nlen); len = nlen - 1; - CALLOC_GOTO(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + len + 1); + CALLOC_GOTO(sp, tqp, 1, sizeof(TAGQ) + len + 1); TAILQ_INIT(tqp->tagq); tqp->tag = tqp->buf; memcpy(tqp->tag, np, (tqp->tlen = len) + 1); @@ -1125,9 +1119,8 @@ corrupt: p = msg_print(sp, tname, &nf1); /* Resolve the file name. */ ctag_file(sp, tfp, name, &dname, &dlen); - CALLOC_GOTO(sp, tp, - TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 + - (slen + 1) * sizeof(CHAR_T)); + CALLOC_GOTO(sp, tp, 1, + sizeof(TAG) + dlen + 2 + nlen + 1 + (slen + 1) * sizeof(CHAR_T)); tp->fname = (char *)tp->buf; if (dlen == 1 && *dname == '.') --dlen; diff --git a/ex/ex_txt.c b/ex/ex_txt.c index 4e62a7ecde8c..7b1f3b94c67f 100644 --- a/ex/ex_txt.c +++ b/ex/ex_txt.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_txt.c,v 10.23 2001/06/25 15:19:21 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -406,8 +402,12 @@ txt_dent(SCR *sp, TEXT *tp) * * Count up spaces/tabs needed to get to the target. */ - for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs) - cno += COL_OFF(cno, ts); + cno = 0; + tabs = 0; + if (!O_ISSET(sp, O_EXPANDTAB)) { + for (; cno + COL_OFF(cno, ts) <= scno; ++tabs) + cno += COL_OFF(cno, ts); + } spaces = scno - cno; /* Make sure there's enough room. */ diff --git a/ex/ex_undo.c b/ex/ex_undo.c index 32f35fd58333..6af6ee9ce6fe 100644 --- a/ex/ex_undo.c +++ b/ex/ex_undo.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_undo.c,v 10.7 2001/06/25 15:19:21 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_usage.c b/ex/ex_usage.c index b28d8a57271d..e02e592ed544 100644 --- a/ex/ex_usage.c +++ b/ex/ex_usage.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_usage.c,v 10.16 2011/12/21 19:26:48 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -170,7 +166,8 @@ nokey: (void)ex_printf(sp, else (void)ex_printf(sp, " Key:%s%s\nUsage: %s\n", - isblank(*kp->help) ? "" : " ", kp->help, kp->usage); + isblank((u_char)*kp->help) ? "" : " ", + kp->help, kp->usage); break; case 0: for (key = 0; key <= MAXVIKEY && !INTERRUPTED(sp); ++key) { diff --git a/ex/ex_util.c b/ex/ex_util.c index 6071fe2db9c8..f3aee410f8ad 100644 --- a/ex/ex_util.c +++ b/ex/ex_util.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_util.c,v 10.32 2001/06/25 15:19:21 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_version.c b/ex/ex_version.c index dc18aa1a9aeb..63a513cdd479 100644 --- a/ex/ex_version.c +++ b/ex/ex_version.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_version.c,v 10.32 2001/06/25 15:19:22 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_visual.c b/ex/ex_visual.c index bfad97c6ea31..b3bcdc191abb 100644 --- a/ex/ex_visual.c +++ b/ex/ex_visual.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_visual.c,v 10.16 2001/08/29 11:04:13 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_write.c b/ex/ex_write.c index 18a578ca816c..d917a384b8af 100644 --- a/ex/ex_write.c +++ b/ex/ex_write.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_write.c,v 10.43 2015/04/03 15:18:45 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_yank.c b/ex/ex_yank.c index 5d1be5a8800d..772b6c74c590 100644 --- a/ex/ex_yank.c +++ b/ex/ex_yank.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_yank.c,v 10.8 2001/06/25 15:19:22 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/ex_z.c b/ex/ex_z.c index fff80d8d282b..fb461f817891 100644 --- a/ex/ex_z.c +++ b/ex/ex_z.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: ex_z.c,v 10.12 2001/06/25 15:19:22 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/ex/extern.h b/ex/extern.h deleted file mode 100644 index ed1e1b793172..000000000000 --- a/ex/extern.h +++ /dev/null @@ -1,130 +0,0 @@ -int ex(SCR **); -int ex_cmd(SCR *); -int ex_range(SCR *, EXCMD *, int *); -int ex_is_abbrev(CHAR_T *, size_t); -int ex_is_unmap(CHAR_T *, size_t); -void ex_badaddr - (SCR *, EXCMDLIST const *, enum badaddr, enum nresult); -int ex_abbr(SCR *, EXCMD *); -int ex_unabbr(SCR *, EXCMD *); -int ex_append(SCR *, EXCMD *); -int ex_change(SCR *, EXCMD *); -int ex_insert(SCR *, EXCMD *); -int ex_next(SCR *, EXCMD *); -int ex_prev(SCR *, EXCMD *); -int ex_rew(SCR *, EXCMD *); -int ex_args(SCR *, EXCMD *); -char **ex_buildargv(SCR *, EXCMD *, char *); -int argv_init(SCR *, EXCMD *); -int argv_exp0(SCR *, EXCMD *, CHAR_T *, size_t); -int argv_exp1(SCR *, EXCMD *, CHAR_T *, size_t, int); -int argv_exp2(SCR *, EXCMD *, CHAR_T *, size_t); -int argv_exp3(SCR *, EXCMD *, CHAR_T *, size_t); -int argv_flt_ex(SCR *, EXCMD *, CHAR_T *, size_t); -int argv_free(SCR *); -int argv_flt_path(SCR *, EXCMD *, CHAR_T *, size_t); -CHAR_T *argv_esc(SCR *, EXCMD *, CHAR_T *, size_t); -CHAR_T *argv_uesc(SCR *, EXCMD *, CHAR_T *, size_t); -int ex_at(SCR *, EXCMD *); -int ex_bang(SCR *, EXCMD *); -int ex_cd(SCR *, EXCMD *); -int ex_cscope(SCR *, EXCMD *); -int cscope_end(SCR *); -int cscope_display(SCR *); -int cscope_search(SCR *, TAGQ *, TAG *); -int ex_delete(SCR *, EXCMD *); -int ex_display(SCR *, EXCMD *); -int ex_edit(SCR *, EXCMD *); -int ex_equal(SCR *, EXCMD *); -int ex_file(SCR *, EXCMD *); -int ex_filter(SCR *, - EXCMD *, MARK *, MARK *, MARK *, CHAR_T *, enum filtertype); -int ex_global(SCR *, EXCMD *); -int ex_v(SCR *, EXCMD *); -int ex_g_insdel(SCR *, lnop_t, recno_t); -int ex_screen_copy(SCR *, SCR *); -int ex_screen_end(SCR *); -int ex_optchange(SCR *, int, char *, u_long *); -int ex_exrc(SCR *); -int ex_run_str(SCR *, char *, CHAR_T *, size_t, int, int); -int ex_join(SCR *, EXCMD *); -int ex_map(SCR *, EXCMD *); -int ex_unmap(SCR *, EXCMD *); -int ex_mark(SCR *, EXCMD *); -int ex_mkexrc(SCR *, EXCMD *); -int ex_copy(SCR *, EXCMD *); -int ex_move(SCR *, EXCMD *); -int ex_open(SCR *, EXCMD *); -int ex_preserve(SCR *, EXCMD *); -int ex_recover(SCR *, EXCMD *); -int ex_list(SCR *, EXCMD *); -int ex_number(SCR *, EXCMD *); -int ex_pr(SCR *, EXCMD *); -int ex_print(SCR *, EXCMD *, MARK *, MARK *, u_int32_t); -int ex_ldisplay(SCR *, const CHAR_T *, size_t, size_t, u_int); -int ex_scprint(SCR *, MARK *, MARK *); -int ex_printf(SCR *, const char *, ...); -int ex_puts(SCR *, const char *); -int ex_fflush(SCR *sp); -int ex_put(SCR *, EXCMD *); -int ex_quit(SCR *, EXCMD *); -int ex_read(SCR *, EXCMD *); -int ex_readfp(SCR *, char *, FILE *, MARK *, recno_t *, int); -int ex_bg(SCR *, EXCMD *); -int ex_fg(SCR *, EXCMD *); -int ex_resize(SCR *, EXCMD *); -int ex_sdisplay(SCR *); -int ex_script(SCR *, EXCMD *); -int sscr_exec(SCR *, recno_t); -int sscr_input(SCR *); -int sscr_end(SCR *); -int ex_set(SCR *, EXCMD *); -int ex_shell(SCR *, EXCMD *); -int ex_exec_proc(SCR *, EXCMD *, char *, const char *, int); -int proc_wait(SCR *, long, const char *, int, int); -int ex_shiftl(SCR *, EXCMD *); -int ex_shiftr(SCR *, EXCMD *); -int ex_source(SCR *, EXCMD *); -int ex_stop(SCR *, EXCMD *); -int ex_s(SCR *, EXCMD *); -int ex_subagain(SCR *, EXCMD *); -int ex_subtilde(SCR *, EXCMD *); -int re_compile(SCR *, - CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int); -void re_error(SCR *, int, regex_t *); -int ex_tag_first(SCR *, CHAR_T *); -int ex_tag_push(SCR *, EXCMD *); -int ex_tag_next(SCR *, EXCMD *); -int ex_tag_prev(SCR *, EXCMD *); -int ex_tag_nswitch(SCR *, TAG *, int); -int ex_tag_Nswitch(SCR *, TAG *, int); -int ex_tag_pop(SCR *, EXCMD *); -int ex_tag_top(SCR *, EXCMD *); -int ex_tag_display(SCR *); -int ex_tag_copy(SCR *, SCR *); -int tagq_free(SCR *, TAGQ *); -int tagq_push(SCR*, TAGQ*, int, int ); -void tag_msg(SCR *, tagmsg_t, char *); -int ex_tagf_alloc(SCR *, char *); -int ex_tag_free(SCR *); -int ex_txt(SCR *, TEXTH *, ARG_CHAR_T, u_int32_t); -int ex_undo(SCR *, EXCMD *); -int ex_help(SCR *, EXCMD *); -int ex_usage(SCR *, EXCMD *); -int ex_viusage(SCR *, EXCMD *); -void ex_cinit(SCR *, EXCMD *, int, int, recno_t, recno_t, int); -int ex_getline(SCR *, FILE *, size_t *); -int ex_ncheck(SCR *, int); -int ex_init(SCR *); -void ex_wemsg(SCR *, CHAR_T *, exm_t); -void ex_emsg(SCR *, char *, exm_t); -int ex_version(SCR *, EXCMD *); -int ex_visual(SCR *, EXCMD *); -int ex_wn(SCR *, EXCMD *); -int ex_wq(SCR *, EXCMD *); -int ex_write(SCR *, EXCMD *); -int ex_xit(SCR *, EXCMD *); -int ex_writefp(SCR *, - char *, FILE *, MARK *, MARK *, u_long *, u_long *, int); -int ex_yank(SCR *, EXCMD *); -int ex_z(SCR *, EXCMD *); diff --git a/ex/script.h b/ex/script.h index 3952e96aea1e..1be6493853d2 100644 --- a/ex/script.h +++ b/ex/script.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: script.h,v 10.3 2012/04/21 23:51:46 zy Exp $ */ struct _script { diff --git a/ex/tag.h b/ex/tag.h index 7d3b2476575b..d0d2a793bcd8 100644 --- a/ex/tag.h +++ b/ex/tag.h @@ -7,8 +7,6 @@ * Rob Mayoff. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: tag.h,v 10.9 2012/07/06 16:38:36 zy Exp $ */ /* diff --git a/ex/version.h b/ex/version.h deleted file mode 100644 index e079bc6ca88a..000000000000 --- a/ex/version.h +++ /dev/null @@ -1 +0,0 @@ -#define VI_VERSION "2.1.3 (2015-04-08)" diff --git a/files/config.h.in b/files/config.h.in new file mode 100644 index 000000000000..f592f3551a54 --- /dev/null +++ b/files/config.h.in @@ -0,0 +1,17 @@ +/* Define when using wide characters */ +#cmakedefine USE_WIDECHAR + +/* Define when iconv can be used */ +#cmakedefine USE_ICONV + +/* Define when the 2nd argument of iconv(3) is not const */ +#cmakedefine ICONV_TRADITIONAL + +/* Define if you have */ +#cmakedefine HAVE_LIBUTIL_H + +/* Define if you have */ +#cmakedefine HAVE_NCURSES_H + +/* Define if you have */ +#cmakedefine HAVE_TERM_H diff --git a/files/pathnames.h.in b/files/pathnames.h.in new file mode 100644 index 000000000000..f1c2821f41c0 --- /dev/null +++ b/files/pathnames.h.in @@ -0,0 +1,26 @@ +/* Read standard system paths first. */ +#include + +#ifndef _PATH_EXRC +#define _PATH_EXRC ".exrc" +#endif + +#ifndef _PATH_MSGCAT +#define _PATH_MSGCAT "@vi_cv_path_msgcat@" +#endif + +#ifndef _PATH_NEXRC +#define _PATH_NEXRC ".nexrc" +#endif + +#ifndef _PATH_PRESERVE +#define _PATH_PRESERVE "@vi_cv_path_preserve@" +#endif + +#ifndef _PATH_SYSEXRC +#define _PATH_SYSEXRC "/etc/vi.exrc" +#endif + +#ifndef _PATH_TAGS +#define _PATH_TAGS "tags" +#endif diff --git a/files/recover.in b/files/recover.in new file mode 100644 index 000000000000..90e1e13ee07c --- /dev/null +++ b/files/recover.in @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Script to recover nvi edit sessions. + +RECDIR="@vi_cv_path_preserve@" + +[ -d ${RECDIR} ] || exit 1 +find ${RECDIR} ! -type f -a ! -type d -delete + +# Check editor backup files. +vibackup=`echo ${RECDIR}/vi.*` +if [ "${vibackup}" != '${RECDIR}/vi.*' ]; then + echo -n 'Recovering vi editor sessions:' + for i in ${RECDIR}/vi.*; do + # Only test files that are readable. + if [ ! -r "${i}" ]; then + continue + fi + + # Unmodified nvi editor backup files either have the + # execute bit set or are zero length. Delete them. + if [ -x "${i}" -o ! -s "${i}" ]; then + rm -f "${i}" + fi + done +else exit +fi + +# It is possible to get incomplete recovery files, if the editor crashes +# at the right time. +virecovery=`echo ${RECDIR}/recover.*` +if [ "${virecovery}" != "${RECDIR}/recover.*" ]; then + for i in ${RECDIR}/recover.*; do + # Only test files that are readable. + if [ ! -r "${i}" ]; then + continue + fi + + # Delete any recovery files that are zero length, corrupted, + # or that have no corresponding backup file. Else send mail + # to the user. + recfile=`awk '/^X-vi-data: *file;/ { sub(/^.*;/, " "); \ + do { if (substr($0,1,1) == " ") print; else exit } \ + while(getline) }' < "${i}" | uudecode -mr` + if [ -n "${recfile}" -a -s "${recfile}" ]; then + sendmail -odb -t < "${i}" + echo -n '.' + else + rm -f "${i}" + fi + done +fi +echo ' done.' diff --git a/docs/man/vi.1 b/man/vi.1 similarity index 98% rename from docs/man/vi.1 rename to man/vi.1 index 73ebdbdb7e13..fcbc1531d9ac 100644 --- a/docs/man/vi.1 +++ b/man/vi.1 @@ -12,8 +12,6 @@ .\" that you would have purchased it, or if any company wishes to .\" redistribute it, contributions to the authors would be appreciated. .\" -.\" $Id: vi.1,v 9.0 2013/11/02 12:11:56 zy Exp $ -.\" .Dd November 2, 2013 .Dt VI 1 .Os @@ -353,7 +351,7 @@ matches the beginning of the word. .Sq \e> matches the end of the word. .It -.Sq \(a~ +.Sq \(ti matches the replacement part of the last .Cm substitute command. @@ -403,7 +401,7 @@ commands depend on their associated motion command: .Cm F , .Cm T , .Cm W , -.Cm ^ , +.Cm \(ha , .Cm b , .Cm e , .Cm f @@ -711,7 +709,7 @@ command being entered, or cancel it if it is only partial. .It Aq Cm control-] Push a tag reference onto the tag stack. .Pp -.It Aq Cm control-^ +.It Aq Cm control-\(ha Switch to the most recently edited file. .Pp .It Xo @@ -981,7 +979,11 @@ command. .Cm ;\& .Xc Repeat the last character find -.Pq i.e., the last .Cm F , f , T No or Cm t No command +(i.e., the last +.Cm F , f , T +or +.Cm t +command) .Ar count times. .Pp @@ -1259,7 +1261,7 @@ Move forward .Ar count section boundaries. .Pp -.It Cm ^ +.It Cm \(ha Move to the first non-blank character on the current line. .Pp .It Xo @@ -1500,7 +1502,7 @@ in the center of the screen. Place the line .Ar count1 at the bottom of the screen. -.It Cm ^ +.It Cm \(ha If .Ar count1 is given, @@ -1540,7 +1542,7 @@ paragraphs. .Pp .It Xo .Op Ar count -.Cm ~ +.Cm \(ti .Ar motion .Xc If the @@ -1553,7 +1555,7 @@ can be specified. Otherwise .Ar motion is mandatory and -.Cm ~ +.Cm \(ti reverses the case of the characters in a text region specified by the .Ar count and @@ -1581,7 +1583,7 @@ Erase to the previous .Ar shiftwidth column boundary. .Pp -.It Cm ^ Ns Aq Cm control-D +.It Cm \(ha Ns Aq Cm control-D Erase all of the autoindent characters, and reset the autoindent level. .Pp .It Cm 0 Ns Aq Cm control-D @@ -1595,6 +1597,11 @@ and characters to move forward to the next .Ar shiftwidth column boundary. +If the +.Cm expandtab +option is set, only insert +.Aq space +characters. .Pp .It Aq Cm erase .It Aq Cm control-H @@ -2028,7 +2035,7 @@ commands from a file. .Xc .It Xo .Op Ar range -.Cm ~ +.Cm \(ti .Op Ar options .Op Ar count .Op Ar flags @@ -2041,7 +2048,7 @@ field may contain any of the following sequences: .It Sq \*(Am The text matched by .Ar pattern . -.It Sq \(a~ +.It Sq \(ti The replacement part of the previous .Cm substitute command. @@ -2298,6 +2305,20 @@ The tenths of a second waits for a subsequent key to complete an .Aq escape key mapping. +.It Cm expandtab , et Bq off +Expand +.Aq tab +characters to +.Aq space +when inserting, replacing or shifting text, autoindenting, +indenting with +.Aq Ic control-T , +outdenting with +.Aq Ic control-D , +or +when filtering lines with the +.Cm !\& +command. .It Cm exrc , ex Bq off Read the startup files in the local directory. .It Cm extended Bq off @@ -2449,7 +2470,7 @@ commands. Turns off all access to external programs. .It Cm shell , sh Bo environment variable Ev SHELL , or Pa /bin/sh Bc Select the shell used by the editor. -.It Cm shellmeta Bq ~{[*?$\`\(aq\&"\e +.It Cm shellmeta Bq \(ti{[*?$\`\(aq\&"\e Set the meta characters checked to determine if file name expansion is necessary. .It Cm shiftwidth , sw Bq 8 @@ -2490,7 +2511,7 @@ This option has historically made editor messages less verbose. It has no effect in this implementation. .It Cm tildeop Bq off Modify the -.Cm ~ +.Cm \(ti command to take an associated motion. .It Cm timeout , to Bq on Time out on keys which may be mapped. diff --git a/vi/extern.h b/vi/extern.h deleted file mode 100644 index 8e145c6318ef..000000000000 --- a/vi/extern.h +++ /dev/null @@ -1,145 +0,0 @@ -int cs_init(SCR *, VCS *); -int cs_next(SCR *, VCS *); -int cs_fspace(SCR *, VCS *); -int cs_fblank(SCR *, VCS *); -int cs_prev(SCR *, VCS *); -int cs_bblank(SCR *, VCS *); -int v_at(SCR *, VICMD *); -int v_chrepeat(SCR *, VICMD *); -int v_chrrepeat(SCR *, VICMD *); -int v_cht(SCR *, VICMD *); -int v_chf(SCR *, VICMD *); -int v_chT(SCR *, VICMD *); -int v_chF(SCR *, VICMD *); -int v_delete(SCR *, VICMD *); -int v_again(SCR *, VICMD *); -int v_exmode(SCR *, VICMD *); -int v_join(SCR *, VICMD *); -int v_shiftl(SCR *, VICMD *); -int v_shiftr(SCR *, VICMD *); -int v_suspend(SCR *, VICMD *); -int v_switch(SCR *, VICMD *); -int v_tagpush(SCR *, VICMD *); -int v_tagpop(SCR *, VICMD *); -int v_filter(SCR *, VICMD *); -int v_ex(SCR *, VICMD *); -int v_ecl_exec(SCR *); -int v_increment(SCR *, VICMD *); -int v_screen_copy(SCR *, SCR *); -int v_screen_end(SCR *); -int v_optchange(SCR *, int, char *, u_long *); -int v_iA(SCR *, VICMD *); -int v_ia(SCR *, VICMD *); -int v_iI(SCR *, VICMD *); -int v_ii(SCR *, VICMD *); -int v_iO(SCR *, VICMD *); -int v_io(SCR *, VICMD *); -int v_change(SCR *, VICMD *); -int v_Replace(SCR *, VICMD *); -int v_subst(SCR *, VICMD *); -int v_left(SCR *, VICMD *); -int v_cfirst(SCR *, VICMD *); -int v_first(SCR *, VICMD *); -int v_ncol(SCR *, VICMD *); -int v_zero(SCR *, VICMD *); -int v_mark(SCR *, VICMD *); -int v_bmark(SCR *, VICMD *); -int v_fmark(SCR *, VICMD *); -int v_emark(SCR *, VICMD *); -int v_match(SCR *, VICMD *); -int v_buildmcs(SCR *, char *); -int v_paragraphf(SCR *, VICMD *); -int v_paragraphb(SCR *, VICMD *); -int v_buildps(SCR *, char *, char *); -int v_Put(SCR *, VICMD *); -int v_put(SCR *, VICMD *); -int v_redraw(SCR *, VICMD *); -int v_replace(SCR *, VICMD *); -int v_right(SCR *, VICMD *); -int v_dollar(SCR *, VICMD *); -int v_screen(SCR *, VICMD *); -int v_lgoto(SCR *, VICMD *); -int v_home(SCR *, VICMD *); -int v_middle(SCR *, VICMD *); -int v_bottom(SCR *, VICMD *); -int v_up(SCR *, VICMD *); -int v_cr(SCR *, VICMD *); -int v_down(SCR *, VICMD *); -int v_hpageup(SCR *, VICMD *); -int v_hpagedown(SCR *, VICMD *); -int v_pagedown(SCR *, VICMD *); -int v_pageup(SCR *, VICMD *); -int v_lineup(SCR *, VICMD *); -int v_linedown(SCR *, VICMD *); -int v_searchb(SCR *, VICMD *); -int v_searchf(SCR *, VICMD *); -int v_searchN(SCR *, VICMD *); -int v_searchn(SCR *, VICMD *); -int v_searchw(SCR *, VICMD *); -int v_correct(SCR *, VICMD *, int); -int v_sectionf(SCR *, VICMD *); -int v_sectionb(SCR *, VICMD *); -int v_sentencef(SCR *, VICMD *); -int v_sentenceb(SCR *, VICMD *); -int v_status(SCR *, VICMD *); -int v_tcmd(SCR *, VICMD *, ARG_CHAR_T, u_int); -int v_txt(SCR *, VICMD *, MARK *, - const CHAR_T *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t); -int v_txt_auto(SCR *, recno_t, TEXT *, size_t, TEXT *); -int v_ulcase(SCR *, VICMD *); -int v_mulcase(SCR *, VICMD *); -int v_Undo(SCR *, VICMD *); -int v_undo(SCR *, VICMD *); -void v_eof(SCR *, MARK *); -void v_eol(SCR *, MARK *); -void v_nomove(SCR *); -void v_sof(SCR *, MARK *); -void v_sol(SCR *); -int v_isempty(CHAR_T *, size_t); -void v_emsg(SCR *, char *, vim_t); -int v_wordW(SCR *, VICMD *); -int v_wordw(SCR *, VICMD *); -int v_wordE(SCR *, VICMD *); -int v_worde(SCR *, VICMD *); -int v_wordB(SCR *, VICMD *); -int v_wordb(SCR *, VICMD *); -int v_xchar(SCR *, VICMD *); -int v_Xchar(SCR *, VICMD *); -int v_yank(SCR *, VICMD *); -int v_z(SCR *, VICMD *); -int vs_crel(SCR *, long); -int v_zexit(SCR *, VICMD *); -int vi(SCR **); -int v_curword(SCR *); -int vs_line(SCR *, SMAP *, size_t *, size_t *); -int vs_number(SCR *); -void vs_busy(SCR *, const char *, busy_t); -void vs_home(SCR *); -void vs_update(SCR *, const char *, const CHAR_T *); -void vs_msg(SCR *, mtype_t, char *, size_t); -int vs_ex_resolve(SCR *, int *); -int vs_resolve(SCR *, SCR *, int); -int vs_repaint(SCR *, EVENT *); -int vs_refresh(SCR *, int); -int vs_column(SCR *, size_t *); -size_t vs_screens(SCR *, recno_t, size_t *); -size_t vs_columns(SCR *, CHAR_T *, recno_t, size_t *, size_t *); -size_t vs_rcm(SCR *, recno_t, int); -size_t vs_colpos(SCR *, recno_t, size_t); -int vs_change(SCR *, recno_t, lnop_t); -int vs_sm_fill(SCR *, recno_t, pos_t); -int vs_sm_scroll(SCR *, MARK *, recno_t, scroll_t); -int vs_sm_1up(SCR *); -int vs_sm_1down(SCR *); -int vs_sm_next(SCR *, SMAP *, SMAP *); -int vs_sm_prev(SCR *, SMAP *, SMAP *); -int vs_sm_cursor(SCR *, SMAP **); -int vs_sm_position(SCR *, MARK *, u_long, pos_t); -recno_t vs_sm_nlines(SCR *, SMAP *, recno_t, size_t); -int vs_split(SCR *, SCR *, int); -int vs_vsplit(SCR *, SCR *); -int vs_discard(SCR *, SCR **); -int vs_fg(SCR *, SCR **, CHAR_T *, int); -int vs_bg(SCR *); -int vs_swap(SCR *, SCR **, char *); -int vs_resize(SCR *, long, adj_t); diff --git a/vi/getc.c b/vi/getc.c index 1d2dc2b627d4..a99c62b6122d 100644 --- a/vi/getc.c +++ b/vi/getc.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: getc.c,v 10.13 2011/12/27 00:49:31 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_at.c b/vi/v_at.c index 96e1616b732e..5ca0f1da3ed7 100644 --- a/vi/v_at.c +++ b/vi/v_at.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_at.c,v 10.11 2001/06/25 15:19:30 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_ch.c b/vi/v_ch.c index 86bd53247115..85a2693e51e2 100644 --- a/vi/v_ch.c +++ b/vi/v_ch.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_ch.c,v 10.11 2011/12/02 19:49:50 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -196,6 +192,15 @@ v_chT(SCR *sp, VICMD *vp) if (v_chF(sp, vp)) return (1); + /* + * Check whether the matching character is to the immediate left + * of the original cursor position, offset adjusted for a motion + * command. If so, no movement is required. + */ + if (vp->m_start.cno == vp->m_stop.cno) { + return (1); + } + /* * v_chF places the cursor on the character, where the 'T' * command wants it to its right. We know this is safe since diff --git a/vi/v_cmd.c b/vi/v_cmd.c index f77cd273cf08..bf367cdacec7 100644 --- a/vi/v_cmd.c +++ b/vi/v_cmd.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_cmd.c,v 10.9 1996/03/28 15:18:39 bostic Exp $"; -#endif /* not lint */ - #include #include #include @@ -130,7 +126,7 @@ VIKEYS const vikeys [MAXVIKEY + 1] = { /* 034 ^\ */ {v_exmode, 0, "^\\", - " ^\\ switch to ex mode"}, + "^\\ switch to ex mode"}, /* 035 ^] */ {v_tagpush, V_ABS|V_KEYW|VM_RCM_SET, "^]", diff --git a/vi/v_delete.c b/vi/v_delete.c index b36808edd2f9..45b945d7e8f6 100644 --- a/vi/v_delete.c +++ b/vi/v_delete.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_delete.c,v 10.11 2001/06/25 15:19:31 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_ex.c b/vi/v_ex.c index c6c1133c78d6..1f2bf0cd6ee0 100644 --- a/vi/v_ex.c +++ b/vi/v_ex.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_ex.c,v 10.61 2011/12/22 18:41:53 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_increment.c b/vi/v_increment.c index 0293425cb4ab..6c59836cab7e 100644 --- a/vi/v_increment.c +++ b/vi/v_increment.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_increment.c,v 10.17 2011/12/02 01:17:53 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_init.c b/vi/v_init.c index a9966323f4a0..21181a79e26b 100644 --- a/vi/v_init.c +++ b/vi/v_init.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_init.c,v 10.10 2012/02/11 00:33:46 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -39,7 +35,7 @@ v_screen_copy(SCR *orig, SCR *sp) VI_PRIVATE *ovip, *nvip; /* Create the private vi structure. */ - CALLOC_RET(orig, nvip, VI_PRIVATE *, 1, sizeof(VI_PRIVATE)); + CALLOC_RET(orig, nvip, 1, sizeof(VI_PRIVATE)); sp->vi_private = nvip; /* Invalidate the line size cache. */ @@ -52,7 +48,7 @@ v_screen_copy(SCR *orig, SCR *sp) /* User can replay the last input, but nothing else. */ if (ovip->rep_len != 0) { - MALLOC_RET(orig, nvip->rep, EVENT *, ovip->rep_len); + MALLOC_RET(orig, nvip->rep, ovip->rep_len); memmove(nvip->rep, ovip->rep, ovip->rep_len); nvip->rep_len = ovip->rep_len; } @@ -88,17 +84,12 @@ v_screen_end(SCR *sp) if ((vip = VIP(sp)) == NULL) return (0); - if (vip->keyw != NULL) - free(vip->keyw); - if (vip->rep != NULL) - free(vip->rep); - if (vip->mcs != NULL) - free(vip->mcs); - if (vip->ps != NULL) - free(vip->ps); + free(vip->keyw); + free(vip->rep); + free(vip->mcs); + free(vip->ps); - if (HMAP != NULL) - free(HMAP); + free(HMAP); free(vip); sp->vi_private = NULL; diff --git a/vi/v_itxt.c b/vi/v_itxt.c index 64460921f2f9..704a0c322176 100644 --- a/vi/v_itxt.c +++ b/vi/v_itxt.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_itxt.c,v 10.21 2001/06/25 15:19:32 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_left.c b/vi/v_left.c index dd7ccb894876..2e3e5d1077c6 100644 --- a/vi/v_left.c +++ b/vi/v_left.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_left.c,v 10.9 2001/06/25 15:19:32 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_mark.c b/vi/v_mark.c index 2254fd334a46..41c31feab711 100644 --- a/vi/v_mark.c +++ b/vi/v_mark.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_mark.c,v 10.12 2001/06/25 15:19:32 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_match.c b/vi/v_match.c index 503c65c731fb..255a0489ca62 100644 --- a/vi/v_match.c +++ b/vi/v_match.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_match.c,v 10.11 2012/02/11 00:33:46 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -162,9 +158,8 @@ v_buildmcs(SCR *sp, char *str) CHAR_T **mp = &VIP(sp)->mcs; size_t len = strlen(str) + 1; - if (*mp != NULL) - free(*mp); - MALLOC(sp, *mp, CHAR_T *, len * sizeof(CHAR_T)); + free(*mp); + MALLOC(sp, *mp, len * sizeof(CHAR_T)); if (*mp == NULL) return (1); #ifdef USE_WIDECHAR diff --git a/vi/v_paragraph.c b/vi/v_paragraph.c index 2cc40b1e5968..e3fdce969695 100644 --- a/vi/v_paragraph.c +++ b/vi/v_paragraph.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_paragraph.c,v 10.10 2001/06/25 15:19:32 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -325,11 +321,10 @@ v_buildps(SCR *sp, char *p_p, char *s_p) if (p_len == 0 && s_len == 0) return (0); - MALLOC_RET(sp, p, char *, p_len + s_len + 1); + MALLOC_RET(sp, p, p_len + s_len + 1); vip = VIP(sp); - if (vip->ps != NULL) - free(vip->ps); + free(vip->ps); if (p_p != NULL) memmove(p, p_p, p_len + 1); diff --git a/vi/v_put.c b/vi/v_put.c index 8843c6933ce2..16011167ce5d 100644 --- a/vi/v_put.c +++ b/vi/v_put.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_put.c,v 10.6 2001/06/25 15:19:34 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_redraw.c b/vi/v_redraw.c index 5549546a1643..de6ed0079701 100644 --- a/vi/v_redraw.c +++ b/vi/v_redraw.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_redraw.c,v 10.7 2001/06/25 15:19:34 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_replace.c b/vi/v_replace.c index e471df595eaa..c0493e809e24 100644 --- a/vi/v_replace.c +++ b/vi/v_replace.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_replace.c,v 10.24 2001/06/25 15:19:34 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_right.c b/vi/v_right.c index bfcf8dd62d72..5f95a962ea6f 100644 --- a/vi/v_right.c +++ b/vi/v_right.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_right.c,v 10.8 2001/06/25 15:19:34 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_screen.c b/vi/v_screen.c index 97c60e4ff140..be867f4dcd0c 100644 --- a/vi/v_screen.c +++ b/vi/v_screen.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_screen.c,v 10.12 2001/06/25 15:19:34 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_scroll.c b/vi/v_scroll.c index 35c01a05fdd0..1ee5fcb5eb17 100644 --- a/vi/v_scroll.c +++ b/vi/v_scroll.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_scroll.c,v 10.12 2001/06/25 15:19:34 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -316,7 +312,7 @@ v_hpagedown(SCR *sp, VICMD *vp) * !!! * Historic vi did not move to the EOF if the screen couldn't move, i.e. * if EOF was already displayed on the screen. This implementation does - * move to EOF in that case, making ^F more like the the historic ^D. + * move to EOF in that case, making ^F more like the historic ^D. * * PUBLIC: int v_pagedown(SCR *, VICMD *); */ @@ -362,7 +358,7 @@ v_pagedown(SCR *sp, VICMD *vp) * !!! * Historic vi did not move to the SOF if the screen couldn't move, i.e. * if SOF was already displayed on the screen. This implementation does - * move to SOF in that case, making ^B more like the the historic ^U. + * move to SOF in that case, making ^B more like the historic ^U. * * PUBLIC: int v_pageup(SCR *, VICMD *); */ diff --git a/vi/v_search.c b/vi/v_search.c index 59525834d939..b0c343d080eb 100644 --- a/vi/v_search.c +++ b/vi/v_search.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_search.c,v 10.31 2012/02/08 07:26:59 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_section.c b/vi/v_section.c index 3613afeee07f..5314f4621ad0 100644 --- a/vi/v_section.c +++ b/vi/v_section.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_section.c,v 10.10 2001/06/25 15:19:35 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_sentence.c b/vi/v_sentence.c index df108392b83f..3415fbd18937 100644 --- a/vi/v_sentence.c +++ b/vi/v_sentence.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_sentence.c,v 10.9 2001/06/25 15:19:35 skimo Exp $"; -#endif /* not lint */ - #include #include #include @@ -291,7 +287,7 @@ ret: slno = cs.cs_lno; * we can end up where we started. Fix it. */ if (vp->m_start.lno != cs.cs_lno || - vp->m_start.cno != cs.cs_cno) + vp->m_start.cno > cs.cs_cno) goto okret; /* diff --git a/vi/v_status.c b/vi/v_status.c index 0d9afd0e224e..fd4d93691c68 100644 --- a/vi/v_status.c +++ b/vi/v_status.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_status.c,v 10.10 2001/06/25 15:19:35 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_txt.c b/vi/v_txt.c index be4309a1813b..84d20c6ad1c1 100644 --- a/vi/v_txt.c +++ b/vi/v_txt.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_txt.c,v 11.5 2013/05/19 20:37:45 bentley Exp $"; -#endif /* not lint */ - #include #include #include @@ -32,7 +28,7 @@ static const char sccsid[] = "$Id: v_txt.c,v 11.5 2013/05/19 20:37:45 bentley Ex static int txt_abbrev(SCR *, TEXT *, CHAR_T *, int, int *, int *); static void txt_ai_resolve(SCR *, TEXT *, int *); static TEXT *txt_backup(SCR *, TEXTH *, TEXT *, u_int32_t *); -static int txt_dent(SCR *, TEXT *, int); +static int txt_dent(SCR *, TEXT *, int, int); static int txt_emark(SCR *, TEXT *, size_t); static void txt_err(SCR *, TEXTH *); static int txt_fc(SCR *, TEXT *, int *); @@ -615,30 +611,21 @@ replay: if (LF_ISSET(TXT_REPLAY)) { /* * !!! - * If this character was quoted by a K_VLNEXT or a backslash, replace - * the placeholder (a carat or a backslash) with the new character. - * If it was quoted by a K_VLNEXT, we've already adjusted the cursor - * because it has to appear on top of the placeholder character. If - * it was quoted by a backslash, adjust the cursor now, the cursor - * doesn't appear on top of it. Historic practice in both cases. + * If this character was quoted by a K_VLNEXT, replace the placeholder + * (a carat) with the new character. We've already adjusted the cursor + * because it has to appear on top of the placeholder character. + * Historic practice. * * Skip tests for abbreviations; ":ab xa XA" followed by "ixa^V" * doesn't perform an abbreviation. Special case, ^V^J (not ^V^M) is * the same as ^J, historically. */ - if (quote == Q_BTHIS || quote == Q_VTHIS) { + if (quote == Q_VTHIS) { FL_CLR(ec_flags, EC_QUOTED); if (LF_ISSET(TXT_MAPINPUT)) FL_SET(ec_flags, EC_MAPINPUT); - if (quote == Q_BTHIS && - (evp->e_value == K_VERASE || evp->e_value == K_VKILL)) { - quote = Q_NOTSET; - --tp->cno; - ++tp->owrite; - goto insl_ch; - } - if (quote == Q_VTHIS && evp->e_value != K_NL) { + if (evp->e_value != K_NL) { quote = Q_NOTSET; goto insl_ch; } @@ -977,7 +964,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' '; if (tp->ai == 0 || tp->cno > tp->ai + tp->offset) goto ins_ch; - (void)txt_dent(sp, tp, 0); + (void)txt_dent(sp, tp, O_SHIFTWIDTH, 0); break; default: abort(); @@ -1193,34 +1180,9 @@ leftmargin: tp->lb[tp->cno - 1] = ' '; case K_CNTRLT: /* Add autoindent characters. */ if (!LF_ISSET(TXT_CNTRLT)) goto ins_ch; - if (txt_dent(sp, tp, 1)) + if (txt_dent(sp, tp, O_SHIFTWIDTH, 1)) goto err; goto ebuf_chk; - case K_BACKSLASH: /* Quote next erase/kill. */ - /* - * !!! - * Historic vi tried to make abbreviations after a backslash - * escape work. If you did ":ab x y", and inserted "x\^H", - * (assuming the erase character was ^H) you got "x^H", and - * no abbreviation was done. If you inserted "x\z", however, - * it tried to back up and do the abbreviation, i.e. replace - * 'x' with 'y'. The problem was it got it wrong, and you - * ended up with "zy\". - * - * This is really hard to do (you have to remember the - * word/non-word state, for example), and doesn't make any - * sense to me. Both backslash and the characters it - * (usually) escapes will individually trigger the - * abbreviation, so I don't see why the combination of them - * wouldn't. I don't expect to get caught on this one, - * particularly since it never worked right, but I've been - * wrong before. - * - * Do the tests for abbreviations, so ":ab xa XA", - * "ixa\" performs the abbreviation. - */ - quote = Q_BNEXT; - goto insq_ch; case K_VLNEXT: /* Quote next character. */ evp->e_c = '^'; quote = Q_VNEXT; @@ -1242,6 +1204,14 @@ leftmargin: tp->lb[tp->cno - 1] = ' '; case K_HEXCHAR: hexcnt = 1; goto insq_ch; + case K_TAB: + if (sp->showmode != SM_COMMAND && quote != Q_VTHIS && + O_ISSET(sp, O_EXPANDTAB)) { + if (txt_dent(sp, tp, O_TABSTOP, 1)) + goto err; + goto ebuf_chk; + } + goto insq_ch; default: /* Insert the character. */ if (LF_ISSET(TXT_SHOWMATCH)) { CHAR_T *match_chars, *cp; @@ -1365,12 +1335,8 @@ ebuf_chk: if (tp->cno >= tp->len) { } /* Step the quote state forward. */ - if (quote != Q_NOTSET) { - if (quote == Q_BNEXT) - quote = Q_BTHIS; - if (quote == Q_VNEXT) - quote = Q_VTHIS; - } + if (quote == Q_VNEXT) + quote = Q_VTHIS; break; } @@ -1723,13 +1689,19 @@ txt_ai_resolve(SCR *sp, TEXT *tp, int *changedp) /* * If there are no spaces, or no tabs after spaces and less than * ts spaces, it's already minimal. + * Keep analysing if expandtab is set. */ - if (!spaces || (!tab_after_sp && spaces < ts)) + if ((!spaces || (!tab_after_sp && spaces < ts)) && + !O_ISSET(sp, O_EXPANDTAB)) return; /* Count up spaces/tabs needed to get to the target. */ - for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs) - cno += COL_OFF(cno, ts); + cno = 0; + tabs = 0; + if (!O_ISSET(sp, O_EXPANDTAB)) { + for (; cno + COL_OFF(cno, ts) <= scno; ++tabs) + cno += COL_OFF(cno, ts); + } spaces = scno - cno; /* @@ -1888,7 +1860,7 @@ txt_backup(SCR *sp, TEXTH *tiqh, TEXT *tp, u_int32_t *flagsp) * changes. */ static int -txt_dent(SCR *sp, TEXT *tp, int isindent) +txt_dent(SCR *sp, TEXT *tp, int swopt, int isindent) { CHAR_T ch; u_long sw, ts; @@ -1896,7 +1868,7 @@ txt_dent(SCR *sp, TEXT *tp, int isindent) int ai_reset; ts = O_VAL(sp, O_TABSTOP); - sw = O_VAL(sp, O_SHIFTWIDTH); + sw = O_VAL(sp, swopt); /* * Since we don't know what precedes the character(s) being inserted @@ -1963,9 +1935,12 @@ txt_dent(SCR *sp, TEXT *tp, int isindent) if (current >= target) spaces = tabs = 0; else { - for (cno = current, - tabs = 0; cno + COL_OFF(cno, ts) <= target; ++tabs) - cno += COL_OFF(cno, ts); + cno = current; + tabs = 0; + if (!O_ISSET(sp, O_EXPANDTAB)) { + for (; cno + COL_OFF(cno, ts) <= target; ++tabs) + cno += COL_OFF(cno, ts); + } spaces = target - cno; } diff --git a/vi/v_ulcase.c b/vi/v_ulcase.c index 9e306caebb60..63576c172a51 100644 --- a/vi/v_ulcase.c +++ b/vi/v_ulcase.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_ulcase.c,v 10.12 2011/12/02 19:58:32 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_undo.c b/vi/v_undo.c index 6cac736d9c5b..6ca8814fabb4 100644 --- a/vi/v_undo.c +++ b/vi/v_undo.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_undo.c,v 10.6 2001/06/25 15:19:36 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_util.c b/vi/v_util.c index f8f3792e7d76..508b5e39c7b1 100644 --- a/vi/v_util.c +++ b/vi/v_util.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_util.c,v 10.14 2001/06/25 15:19:36 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_word.c b/vi/v_word.c index f07dbb6e359c..1e1e15e2655e 100644 --- a/vi/v_word.c +++ b/vi/v_word.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_word.c,v 10.7 2011/12/27 00:49:31 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_xchar.c b/vi/v_xchar.c index 52fa03a55884..db8bf455e650 100644 --- a/vi/v_xchar.c +++ b/vi/v_xchar.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_xchar.c,v 10.10 2001/06/25 15:19:36 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_yank.c b/vi/v_yank.c index 7322f7336df3..addacd85bc54 100644 --- a/vi/v_yank.c +++ b/vi/v_yank.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_yank.c,v 10.10 2001/06/25 15:19:36 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_z.c b/vi/v_z.c index c95c82d19c38..93b946dfa4eb 100644 --- a/vi/v_z.c +++ b/vi/v_z.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_z.c,v 10.13 2011/12/02 17:26:59 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/v_zexit.c b/vi/v_zexit.c index b9805b337568..3922c585ca7a 100644 --- a/vi/v_zexit.c +++ b/vi/v_zexit.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: v_zexit.c,v 10.7 2001/06/25 15:19:37 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/vi.c b/vi/vi.c index 144d903449a3..27ace47a8ea3 100644 --- a/vi/vi.c +++ b/vi/vi.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vi.c,v 10.61 2011/12/21 13:08:30 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -970,7 +966,7 @@ v_init(SCR *sp) sp->roff = sp->coff = 0; /* Create a screen map. */ - CALLOC_RET(sp, HMAP, SMAP *, SIZE_HMAP(sp), sizeof(SMAP)); + CALLOC_RET(sp, HMAP, SIZE_HMAP(sp), sizeof(SMAP)); TMAP = HMAP + (sp->t_rows - 1); HMAP->lno = sp->lno; HMAP->coff = 0; @@ -1007,10 +1003,8 @@ v_dtoh(SCR *sp) /* Move all screens to the hidden queue, tossing screen maps. */ for (hidden = 0, gp = sp->gp; (tsp = TAILQ_FIRST(gp->dq)) != NULL; ++hidden) { - if (_HMAP(tsp) != NULL) { - free(_HMAP(tsp)); - _HMAP(tsp) = NULL; - } + free(_HMAP(tsp)); + _HMAP(tsp) = NULL; TAILQ_REMOVE(gp->dq, tsp, q); TAILQ_INSERT_TAIL(gp->hq, tsp, q); /* XXXX Change if hidden screens per window */ diff --git a/vi/vi.h b/vi/vi.h index eeb6b9fc0797..fbeceab23790 100644 --- a/vi/vi.h +++ b/vi/vi.h @@ -5,8 +5,6 @@ * Keith Bostic. All rights reserved. * * See the LICENSE file for redistribution information. - * - * $Id: vi.h,v 10.29 2012/02/11 00:33:46 zy Exp $ */ /* Definition of a vi "word". */ @@ -217,7 +215,7 @@ typedef struct _smap { typedef enum { CNOTSET, FSEARCH, fSEARCH, TSEARCH, tSEARCH } cdir_t; typedef enum { AB_NOTSET, AB_NOTWORD, AB_INWORD } abb_t; -typedef enum { Q_NOTSET, Q_BNEXT, Q_BTHIS, Q_VNEXT, Q_VTHIS } quote_t; +typedef enum { Q_NOTSET, Q_VNEXT, Q_VTHIS } quote_t; /* Vi private, per-screen memory. */ typedef struct _vi_private { diff --git a/vi/vs_line.c b/vi/vs_line.c index e523076bf29e..3bb8057ade92 100644 --- a/vi/vs_line.c +++ b/vi/vs_line.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vs_line.c,v 10.40 2012/02/13 19:22:25 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/vs_msg.c b/vi/vs_msg.c index 2eb88e4e7e69..d6144bca692c 100644 --- a/vi/vs_msg.c +++ b/vi/vs_msg.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vs_msg.c,v 10.88 2013/03/19 09:59:03 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -352,16 +348,16 @@ vs_msg(SCR *sp, mtype_t mtype, char *line, size_t len) } vip->mtype = mtype; for (s = line;; s = t) { - for (; len > 0 && isblank(*s); --len, ++s); + for (; len > 0 && isblank((u_char)*s); --len, ++s); if (len == 0) break; if (len + vip->lcontinue > maxcols) { for (e = s + (maxcols - vip->lcontinue); - e > s && !isblank(*e); --e); + e > s && !isblank((u_char)*e); --e); if (e == s) e = t = s + (maxcols - vip->lcontinue); else - for (t = e; isblank(e[-1]); --e); + for (t = e; isblank((u_char)e[-1]); --e); } else e = t = s + len; @@ -875,8 +871,8 @@ vs_msgsave(SCR *sp, mtype_t mt, char *p, size_t len) * allocate memory here, we're genuinely screwed, dump the message * to stderr in the (probably) vain hope that someone will see it. */ - CALLOC_GOTO(sp, mp_n, MSGS *, 1, sizeof(MSGS)); - MALLOC_GOTO(sp, mp_n->buf, char *, len); + CALLOC_GOTO(sp, mp_n, 1, sizeof(MSGS)); + MALLOC_GOTO(sp, mp_n->buf, len); memmove(mp_n->buf, p, len); mp_n->len = len; @@ -894,7 +890,6 @@ vs_msgsave(SCR *sp, mtype_t mt, char *p, size_t len) return; alloc_err: - if (mp_n != NULL) - free(mp_n); + free(mp_n); (void)fprintf(stderr, "%.*s\n", (int)len, p); } diff --git a/vi/vs_refresh.c b/vi/vs_refresh.c index 68b51a12b35b..a512f0a04c00 100644 --- a/vi/vs_refresh.c +++ b/vi/vs_refresh.c @@ -9,16 +9,13 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vs_refresh.c,v 10.54 2015/04/08 16:32:49 zy Exp $"; -#endif /* not lint */ - #include #include #include #include #include +#include #include #include #include @@ -469,7 +466,7 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) && /* Sanity checking. */ if (CNO >= len && len != 0) { msgq(sp, M_ERR, "Error: %s/%d: cno (%zu) >= len (%zu)", - tail(__FILE__), __LINE__, CNO, len); + basename(__FILE__), __LINE__, CNO, len); return (1); } #endif @@ -503,7 +500,7 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) && /* * Count up the widths of the characters. If it's a tab - * character, go do it the the slow way. + * character, go do it the slow way. */ for (cwtotal = 0; cnt--; cwtotal += KEY_COL(sp, ch)) if ((ch = *(UCHAR_T *)p--) == '\t') @@ -541,7 +538,7 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) && /* * Count up the widths of the characters. If it's a tab - * character, go do it the the slow way. If we cross a + * character, go do it the slow way. If we cross a * screen boundary, we can quit. */ for (cwtotal = SCNO; cnt--;) { diff --git a/vi/vs_relative.c b/vi/vs_relative.c index abeb70e68e1f..5df8c3c3f22d 100644 --- a/vi/vs_relative.c +++ b/vi/vs_relative.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vs_relative.c,v 10.19 2011/12/01 15:22:59 zy Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/vs_smap.c b/vi/vs_smap.c index 9dcb8d49b626..971502ebd62b 100644 --- a/vi/vs_smap.c +++ b/vi/vs_smap.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vs_smap.c,v 10.31 2011/02/26 13:56:21 skimo Exp $"; -#endif /* not lint */ - #include #include #include diff --git a/vi/vs_split.c b/vi/vs_split.c index d70b4a184d85..f1c9f8cd1dd6 100644 --- a/vi/vs_split.c +++ b/vi/vs_split.c @@ -9,10 +9,6 @@ #include "config.h" -#ifndef lint -static const char sccsid[] = "$Id: vs_split.c,v 10.43 2015/04/05 15:21:55 zy Exp $"; -#endif /* not lint */ - #include #include #include @@ -64,7 +60,7 @@ vs_split( vs_resolve(sp, NULL, 1); /* Get a new screen map. */ - CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP)); + CALLOC(sp, _HMAP(new), SIZE_HMAP(sp), sizeof(SMAP)); if (_HMAP(new) == NULL) return (1); _HMAP(new)->lno = sp->lno; @@ -224,7 +220,7 @@ vs_vsplit(SCR *sp, SCR *new) vs_resolve(sp, NULL, 1); /* Get a new screen map. */ - CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP)); + CALLOC(sp, _HMAP(new), SIZE_HMAP(sp), sizeof(SMAP)); if (_HMAP(new) == NULL) return (1); _HMAP(new)->lno = sp->lno; @@ -758,7 +754,7 @@ vs_swap(SCR *sp, SCR **nspp, char *name) nsp->defscroll = nsp->t_maxrows / 2; /* Allocate a new screen map. */ - CALLOC_RET(nsp, _HMAP(nsp), SMAP *, SIZE_HMAP(nsp), sizeof(SMAP)); + CALLOC_RET(nsp, _HMAP(nsp), SIZE_HMAP(nsp), sizeof(SMAP)); _TMAP(nsp) = _HMAP(nsp) + (nsp->t_rows - 1); /* Fill the map. */