Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:redwil:15.4
xview
xview-buildsystem.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xview-buildsystem.patch of Package xview
diff -rNu xview-3.2p1.4-old/Build-LinuxXView.bash xview-3.2p1.4/Build-LinuxXView.bash --- xview-3.2p1.4-old/Build-LinuxXView.bash 2013-08-28 17:12:56.436682003 +0200 +++ xview-3.2p1.4/Build-LinuxXView.bash 2013-08-28 21:06:37.188338395 +0200 @@ -16,11 +16,24 @@ exit 1 fi +# DESTDIR is not exported, it helps avoid problems with $(DESTDIR)$(BINDIR) +# in Makefiles +DESTDIR=$_DESTDIR_ + # Set the directories that will be used for installation [ -z "$OPENWINHOME" ] && OPENWINHOME=/usr/openwin -[ -z "$X11DIR" ] && X11DIR=/usr/X11R6 +[ -z "$X11DIR" ] && X11DIR=/usr/X11R6/lib/X11 OWDEST=$DESTDIR$OPENWINHOME -X11DEST=$DESTDIR$X11DIR/lib/X11/config +X11DEST=$DESTDIR$X11DIR/config +ETCDEST=$DESTDIR/etc/openwin + +if [ ! -d "$ETCDEST" ]; then + mkdir -p $ETCDEST +fi + +if [ ! -d "$OWDEST" ]; then + mkdir -p $OWDEST +fi # Generate file that gets appended to every Makefile created by the imake-wrapper @@ -45,7 +58,7 @@ EOF IMAKEAPPEND="`pwd`/imake.append" -IMAKEINCLUDE="-I`pwd`/config -I$BUILDPREFIX/usr/lib/X11/config -I$BUILDPREFIX/usr/X11R6/lib/X11/config -I/usr/lib/X11/config -I/usr/X11R6/lib/X11/config" +IMAKEINCLUDE="-I`pwd`/config -I$BUILDPREFIX/usr/lib/X11/config -I$BUILDPREFIX/usr/X11R6/lib/X11/config -I/usr/lib/X11/config -I/usr/X11R6/lib/X11/config -I/usr/share/X11/config" # Make sure our wrappers are in the path if [ -z "$XVIEW_SETUP" ]; then @@ -56,7 +69,7 @@ PS1='\h:\w(XView-build)\$ ' XVIEW_SETUP=1 export OPENWINHOME X11DIR OWDEST X11DEST IMAKEINCLUDE IMAKEAPPEND \ - PATH PS1 XVIEW_SETUP + PATH PS1 XVIEW_SETUP ETCDEST __LIB__ hash -r # patch doesn't restore the permissions, so make sure our wrapper is @@ -111,19 +124,16 @@ ) || exit $? ;; instfinish) - [ -e $OWDEST/lib/openwin-menu-std ] || mv $OWDEST/lib/openwin-menu $OWDEST/lib/openwin-menu-std - install -d $OWDEST/lib/xview $OWDEST/share/locale/C/props - install -m 644 contrib/misc/openwin-menu* $OWDEST/lib - install -m 755 contrib/misc/Xinitrc $OWDEST/lib + [ -e $ETCDEST/openwin-menu-std ] || mv $ETCDEST/openwin-menu $ETCDEST/openwin-menu-std + install -d $OWDEST/$__LIB__/xview $OWDEST/share/locale/C/props + install -m 644 contrib/misc/openwin-menu* $ETCDEST + install -m 755 contrib/misc/Xinitrc $ETCDEST install -m 755 contrib/misc/{openwin,owplaces} $OWDEST/bin install -m 644 contrib/misc/props-locale.C $OWDEST/share/locale/C/props/C install -m 644 contrib/misc/props-locale.basic_setting $OWDEST/share/locale/C/props/basic_setting [ -e $OWDEST/bin/full1.sed ] && \ - mv $OWDEST/bin/{full[12],minimal[1234]}.sed $OWDEST/lib/xview + mv $OWDEST/bin/{full[12],minimal[1234]}.sed $OWDEST/$__LIB__/xview chmod -R a+rX,u+w,go-w $OWDEST $X11DEST/XView.* - chmod a+x $OWDEST/share/src/xview/examples/bin/* - chown -R root.root $OWDEST $X11DEST/XView.* - [ -z "$DESTDIR" ] || chown -R root.root $DESTDIR/usr ;; tar) DIRNAME="`pwd`" diff -rNu xview-3.2p1.4-old/Imakefile xview-3.2p1.4/Imakefile --- xview-3.2p1.4-old/Imakefile 2013-08-28 17:12:56.432682003 +0200 +++ xview-3.2p1.4/Imakefile 2013-08-28 17:13:08.832682184 +0200 @@ -10,9 +10,6 @@ XCOMM # Top level Imakefile for ProductNameAndRelease XCOMM # @(#)Imakefile 1.7 1/7/92 SMI -CC = cc -CFLAGS = -O - #define IHaveSubdirs #define PassCDebugFlags diff -rNu xview-3.2p1.4-old/clients/olvwm-4.1/Imakefile xview-3.2p1.4/clients/olvwm-4.1/Imakefile --- xview-3.2p1.4-old/clients/olvwm-4.1/Imakefile 2013-08-28 17:12:56.120681998 +0200 +++ xview-3.2p1.4/clients/olvwm-4.1/Imakefile 2013-08-28 17:13:08.832682184 +0200 @@ -1,3 +1,6 @@ +/* dirty hack */ +override CDEBUGFLAGS = -w -O2 + XCOMM # If you want to install the help files for olvwm, set HasInfoFiles to YES #define HasInfoFiles YES @@ -143,7 +146,7 @@ ComplexProgramTarget(olvwm) #if NeedMenuFile -InstallNonExecList($(MISC),$(LIBRARY_DEST)) +InstallNonExecList($(MISC),$(ETCDEST)) #endif clean:: diff -rNu xview-3.2p1.4-old/clients/olvwm-4.1/usermenu.c xview-3.2p1.4/clients/olvwm-4.1/usermenu.c --- xview-3.2p1.4-old/clients/olvwm-4.1/usermenu.c 2013-08-28 17:12:56.116681998 +0200 +++ xview-3.2p1.4/clients/olvwm-4.1/usermenu.c 2013-08-28 17:13:08.836682184 +0200 @@ -938,6 +938,9 @@ /* /usr/openwin/lib/<menufile> */ menuSearchPath[i++] = MemNewString("/usr/openwin/lib/%s"); + /* /etc/openwin/<menufile> */ + menuSearchPath[i++] = MemNewString("/etc/openwin/%s"); + menuSearchPath[i] = (char *)NULL; return menuSearchPath; diff -rNu xview-3.2p1.4-old/clients/olwm/Imakefile xview-3.2p1.4/clients/olwm/Imakefile --- xview-3.2p1.4-old/clients/olwm/Imakefile 2013-08-28 17:12:56.096681998 +0200 +++ xview-3.2p1.4/clients/olwm/Imakefile 2013-08-28 17:13:08.836682184 +0200 @@ -72,6 +72,6 @@ ComplexProgramTarget(olwm) -InstallNonExecList($(MISC),$(LIBRARY_DEST)) +InstallNonExecList($(MISC),$(ETCDEST)) #include <XView.prog> diff -rNu xview-3.2p1.4-old/config/XView.tmpl xview-3.2p1.4/config/XView.tmpl --- xview-3.2p1.4-old/config/XView.tmpl 2013-08-28 17:12:56.288682000 +0200 +++ xview-3.2p1.4/config/XView.tmpl 2013-08-28 17:48:07.052712956 +0200 @@ -23,7 +23,7 @@ * Where to install XView libraries */ #ifndef XVLibraryDestination -#define XVLibraryDestination $(XVDESTDIR)/lib +#define XVLibraryDestination $(XVDESTDIR)/$(__LIB__) #endif /* * Where to install XView lint libraries @@ -50,7 +50,7 @@ */ #if InstallManPagesInXVDestDir # ifndef XVManPath -# define XVManPath $(XVDESTDIR)/man +# define XVManPath $(XVDESTDIR)/share/man # endif #else # define XVManPath ManPath @@ -65,7 +65,7 @@ * Where to install the source examples. */ #ifndef XVSourceDest -#define XVSourceDest $(XVDESTDIR)/share/src/xview +#define XVSourceDest $(XVDESTDIR)/share/xview #endif /* * Where to install the documentation files. @@ -465,4 +465,8 @@ #define CcCmd cc #define LibraryCcCmd cc */ #include <XView.rules> + +/* dirty hack */ +override CDEBUGFLAGS = -w -O2 + #endif /* XViewTmpl */ diff -rNu xview-3.2p1.4-old/contrib/examples/canvas/Imakefile xview-3.2p1.4/contrib/examples/canvas/Imakefile --- xview-3.2p1.4-old/contrib/examples/canvas/Imakefile 2013-08-28 17:12:56.288682000 +0200 +++ xview-3.2p1.4/contrib/examples/canvas/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -20,12 +20,6 @@ PROGRAMS=canvas_event canvas_input line scroll_view split_views -AllTarget($(PROGRAMS)) - -SingleProgramTarget(canvas_event,canvas_event.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(canvas_input,canvas_input.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(line,line.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(scroll_view,scroll_view.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(split_views,split_views.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/color/Imakefile xview-3.2p1.4/contrib/examples/color/Imakefile --- xview-3.2p1.4-old/contrib/examples/color/Imakefile 2013-08-28 17:12:56.288682000 +0200 +++ xview-3.2p1.4/contrib/examples/color/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -23,18 +23,6 @@ PROGRAMS= animate color color_animate color_logo color_objs \ color_panel example1 example2 example3 example4 x_draw -AllTarget($(PROGRAMS)) - -SingleProgramTarget(animate,animate.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(color,color.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(color_animate,color_animate.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(color_logo,color_logo.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(color_objs,color_objs.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(color_panel,color_panel.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(example1,example1.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(example2,example2.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(example3,example3.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(example4,example4.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(x_draw,x_draw.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/cursor/Imakefile xview-3.2p1.4/contrib/examples/cursor/Imakefile --- xview-3.2p1.4-old/contrib/examples/cursor/Imakefile 2013-08-28 17:12:56.292682000 +0200 +++ xview-3.2p1.4/contrib/examples/cursor/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -20,10 +20,6 @@ PROGRAMS= hot_spot simple_cursor stop_cursor -AllTarget($(PROGRAMS)) - -SingleProgramTarget(hot_spot,hot_spot.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_cursor,simple_cursor.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(stop_cursor,stop_cursor.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/defaults/Imakefile xview-3.2p1.4/contrib/examples/defaults/Imakefile --- xview-3.2p1.4-old/contrib/examples/defaults/Imakefile 2013-08-28 17:12:56.292682000 +0200 +++ xview-3.2p1.4/contrib/examples/defaults/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -20,9 +20,6 @@ PROGRAMS= default_size default_text -AllTarget($(PROGRAMS)) - -SingleProgramTarget(default_size,default_size.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(default_text,default_text.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/dnd/Imakefile xview-3.2p1.4/contrib/examples/dnd/Imakefile --- xview-3.2p1.4-old/contrib/examples/dnd/Imakefile 2013-08-28 17:12:56.304682001 +0200 +++ xview-3.2p1.4/contrib/examples/dnd/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -22,10 +22,6 @@ PROGRAMS= dest source1 source2 -AllTarget($(PROGRAMS)) - -SingleProgramTarget(dest,dest.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(source1,source1.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(source2,source2.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/extensions/Imakefile xview-3.2p1.4/contrib/examples/extensions/Imakefile --- xview-3.2p1.4-old/contrib/examples/extensions/Imakefile 2013-08-28 17:12:56.292682000 +0200 +++ xview-3.2p1.4/contrib/examples/extensions/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -44,17 +44,8 @@ PROGRAMS = logo bitmap image -AllTarget($(PROGRAMS)) - -SingleProgramTarget(logo,$(LOGO_OBJS),$(LOCAL_LIBRARIES), /**/) -$(LOGO_OBJS): $(LOGO_HDRS) - -SingleProgramTarget(bitmap,$(BITMAP_OBJS),$(LOCAL_LIBRARIES), /**/) -$(BITMAP_OBJS): $(BITMAP_HDRS) - -SingleProgramTarget(image,$(IMAGE_OBJS),$(LOCAL_LIBRARIES), /**/) -$(IMAGE_OBJS): $(IMAGE_HDRS) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) InstallSrcsSubdirs($(SUBDIRS)) diff -rNu xview-3.2p1.4-old/contrib/examples/fonts/Imakefile xview-3.2p1.4/contrib/examples/fonts/Imakefile --- xview-3.2p1.4-old/contrib/examples/fonts/Imakefile 2013-08-28 17:12:56.292682000 +0200 +++ xview-3.2p1.4/contrib/examples/fonts/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -20,12 +20,6 @@ PROGRAMS= disp_fonts fonts simple_font type_font disp_fonts2 -AllTarget($(PROGRAMS)) - -SingleProgramTarget(disp_fonts,disp_fonts.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(fonts,fonts.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_font,simple_font.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(type_font,type_font.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(disp_fonts2,disp_fonts2.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/frames/Imakefile xview-3.2p1.4/contrib/examples/frames/Imakefile --- xview-3.2p1.4-old/contrib/examples/frames/Imakefile 2013-08-28 17:12:56.292682000 +0200 +++ xview-3.2p1.4/contrib/examples/frames/Imakefile 2013-08-28 17:13:08.840682185 +0200 @@ -22,14 +22,6 @@ PROGRAMS= command_frame done_proc frame_color hdrs_n_footers popup \ simple_frame subframe -AllTarget($(PROGRAMS)) - -SingleProgramTarget(command_frame,command_frame.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(done_proc,done_proc.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(frame_color,frame_color.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(hdrs_n_footers,hdrs_n_footers.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(popup,popup.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_frame,simple_frame.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(subframe,subframe.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/icons/Imakefile xview-3.2p1.4/contrib/examples/icons/Imakefile --- xview-3.2p1.4-old/contrib/examples/icons/Imakefile 2013-08-28 17:12:56.296682001 +0200 +++ xview-3.2p1.4/contrib/examples/icons/Imakefile 2013-08-28 17:13:08.844682185 +0200 @@ -21,9 +21,6 @@ PROGRAMS= icon_demo icon_demo2 -AllTarget($(PROGRAMS)) - -SingleProgramTarget(icon_demo,icon_demo.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(icon_demo2,icon_demo2.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/menus/Imakefile xview-3.2p1.4/contrib/examples/menus/Imakefile --- xview-3.2p1.4-old/contrib/examples/menus/Imakefile 2013-08-28 17:12:56.296682001 +0200 +++ xview-3.2p1.4/contrib/examples/menus/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -20,13 +20,6 @@ PROGRAMS= menu menu_dir menu_dir2 pin_menu simple_menu xv_menu -AllTarget($(PROGRAMS)) - -SingleProgramTarget(menu,menu.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(menu_dir,menu_dir.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(menu_dir2,menu_dir2.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(pin_menu,pin_menu.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_menu,simple_menu.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(xv_menu,xv_menu.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/misc/Imakefile xview-3.2p1.4/contrib/examples/misc/Imakefile --- xview-3.2p1.4-old/contrib/examples/misc/Imakefile 2013-08-28 17:12:56.296682001 +0200 +++ xview-3.2p1.4/contrib/examples/misc/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -23,14 +23,6 @@ PROGRAMS= fullscreen multi_display multiscreen screen \ svrimage vkbd_fonts vkbd_colors -AllTarget($(PROGRAMS)) - -SingleProgramTarget(fullscreen,fullscreen.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(multi_display,multi_display.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(multiscreen,multiscreen.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(screen,screen.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(svrimage,svrimage.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(vkbd_fonts,vkbd_fonts.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(vkbd_colors,vkbd_colors.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/notice/Imakefile xview-3.2p1.4/contrib/examples/notice/Imakefile --- xview-3.2p1.4-old/contrib/examples/notice/Imakefile 2013-08-28 17:12:56.296682001 +0200 +++ xview-3.2p1.4/contrib/examples/notice/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -20,10 +20,6 @@ PROGRAMS= notice simple_notice trigger_notice -AllTarget($(PROGRAMS)) - -SingleProgramTarget(notice,notice.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_notice,simple_notice.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(trigger_notice,trigger_notice.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/notifier/Imakefile xview-3.2p1.4/contrib/examples/notifier/Imakefile --- xview-3.2p1.4-old/contrib/examples/notifier/Imakefile 2013-08-28 17:12:56.296682001 +0200 +++ xview-3.2p1.4/contrib/examples/notifier/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -22,14 +22,6 @@ PROGRAMS= animate interpose notify notify_input ntfy_do_dis \ ntfy_pipe ntfy_sig -AllTarget($(PROGRAMS)) - -SingleProgramTarget(animate,animate.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(interpose,interpose.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(notify,notify.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(notify_input,notify_input.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(ntfy_do_dis,ntfy_do_dis.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(ntfy_pipe,ntfy_pipe.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(ntfy_sig,ntfy_sig.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/panels/Imakefile xview-3.2p1.4/contrib/examples/panels/Imakefile --- xview-3.2p1.4-old/contrib/examples/panels/Imakefile 2013-08-28 17:12:56.300682001 +0200 +++ xview-3.2p1.4/contrib/examples/panels/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -24,19 +24,6 @@ list_6_glyphs panel_repaint quit repaint simple_panel \ slider stop_frame -AllTarget($(PROGRAMS)) - -SingleProgramTarget(btn_menu,btn_menu.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(choices,choices.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(client_data,client_data.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(item_move,item_move.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(list_glyphs,list_glyphs.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(list_6_glyphs,list_6_glyphs.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(panel_repaint,panel_repaint.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(quit,quit.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(repaint,repaint.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_panel,simple_panel.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(slider,slider.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(stop_frame,stop_frame.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/scrollbar/Imakefile xview-3.2p1.4/contrib/examples/scrollbar/Imakefile --- xview-3.2p1.4-old/contrib/examples/scrollbar/Imakefile 2013-08-28 17:12:56.300682001 +0200 +++ xview-3.2p1.4/contrib/examples/scrollbar/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -20,10 +20,6 @@ PROGRAMS= scroll_cells scroll_cells2 scrollto -AllTarget($(PROGRAMS)) - -SingleProgramTarget(scroll_cells,scroll_cells.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(scroll_cells2,scroll_cells2.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(scrollto,scrollto.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/selection/Imakefile xview-3.2p1.4/contrib/examples/selection/Imakefile --- xview-3.2p1.4-old/contrib/examples/selection/Imakefile 2013-08-28 17:12:56.304682001 +0200 +++ xview-3.2p1.4/contrib/examples/selection/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -20,9 +20,6 @@ PROGRAMS= sel_hold sel_req -AllTarget($(PROGRAMS)) - -SingleProgramTarget(sel_hold,sel_hold.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(sel_req,sel_req.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/seln_svc/Imakefile xview-3.2p1.4/contrib/examples/seln_svc/Imakefile --- xview-3.2p1.4-old/contrib/examples/seln_svc/Imakefile 2013-08-28 17:12:56.300682001 +0200 +++ xview-3.2p1.4/contrib/examples/seln_svc/Imakefile 2013-08-28 17:13:08.936682186 +0200 @@ -20,12 +20,6 @@ PROGRAMS= long_seln seln seln_line simple_seln text_seln -AllTarget($(PROGRAMS)) - -SingleProgramTarget(long_seln,long_seln.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(seln,seln.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(seln_line,seln_line.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(simple_seln,simple_seln.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(text_seln,text_seln.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/sv_compat/Imakefile xview-3.2p1.4/contrib/examples/sv_compat/Imakefile --- xview-3.2p1.4-old/contrib/examples/sv_compat/Imakefile 2013-08-28 17:12:56.300682001 +0200 +++ xview-3.2p1.4/contrib/examples/sv_compat/Imakefile 2013-08-28 17:13:08.940682186 +0200 @@ -21,8 +21,6 @@ PROGRAMS= pw_draw -AllTarget($(PROGRAMS)) - -SingleProgramTarget(pw_draw,pw_draw.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/textsw/Imakefile xview-3.2p1.4/contrib/examples/textsw/Imakefile --- xview-3.2p1.4-old/contrib/examples/textsw/Imakefile 2013-08-28 17:12:56.304682001 +0200 +++ xview-3.2p1.4/contrib/examples/textsw/Imakefile 2013-08-28 17:13:08.940682186 +0200 @@ -12,7 +12,7 @@ INCLUDES = -I. -I$(HEADER_DEST) -I$(TOP) DEPLIBS = XViewClientDepLibs LOCAL_LIBRARIES = XViewClientLibs -CURSES_LIBS = -lcurses +CURSES_LIBS = -lncurses -ltinfo MAKEFILE_SIMPLE = Makefile.customer SRCS = sample_tty.c textsw.c textsw.font.c textsw_to_ttysw.c \ @@ -23,13 +23,6 @@ PROGRAMS= sample_tty textsw textsw.font textsw_to_ttysw \ ttycurses xv_termsw -AllTarget($(PROGRAMS)) - -SingleProgramTarget(sample_tty,sample_tty.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(textsw,textsw.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(textsw.font,textsw.font.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(textsw_to_ttysw,textsw_to_ttysw.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(ttycurses,ttycurses.o,$(LOCAL_LIBRARIES),$(CURSES_LIBS)) -SingleProgramTarget(xv_termsw,xv_termsw.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/examples/ttysw/Imakefile xview-3.2p1.4/contrib/examples/ttysw/Imakefile --- xview-3.2p1.4-old/contrib/examples/ttysw/Imakefile 2013-08-28 17:12:56.304682001 +0200 +++ xview-3.2p1.4/contrib/examples/ttysw/Imakefile 2013-08-28 17:13:08.940682186 +0200 @@ -12,7 +12,7 @@ INCLUDES = -I. -I$(HEADER_DEST) -I$(TOP) DEPLIBS = XViewClientDepLibs LOCAL_LIBRARIES = XViewClientLibs -CURSES_LIBS = -lcurses +CURSES_LIBS = -lncurses -ltinfo MAKEFILE_SIMPLE = Makefile.customer SRCS = sample_tty.c textsw_to_ttysw.c \ @@ -23,11 +23,6 @@ PROGRAMS = sample_tty textsw_to_ttysw \ ttycurses xv_termsw -AllTarget($(PROGRAMS)) - -SingleProgramTarget(sample_tty,sample_tty.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(textsw_to_ttysw,textsw_to_ttysw.o,$(LOCAL_LIBRARIES), /**/) -SingleProgramTarget(ttycurses,ttycurses.o,$(LOCAL_LIBRARIES),$(CURSES_LIBS)) -SingleProgramTarget(xv_termsw,xv_termsw.o,$(LOCAL_LIBRARIES), /**/) - -#include <XView.prog> +MakeDirectories(install,$(SRC_DEST)/examples/bin) +MakeDirectories(install.srcs,$(SRC_DEST)/$(LOCATION)) +InstallExampleSrcs($(INSTALL_SRCS),$(MAKEFILE_SIMPLE),$(SRC_DEST)/$(LOCATION)) diff -rNu xview-3.2p1.4-old/contrib/misc/openwin xview-3.2p1.4/contrib/misc/openwin --- xview-3.2p1.4-old/contrib/misc/openwin 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/contrib/misc/openwin 2013-08-28 17:13:08.940682186 +0200 @@ -4,11 +4,11 @@ export XAPPLRESDIR MANPATH HELPPATH OPENWINHOME WINDOWMANAGER X11HOME if [ -z "$OPENWINHOME" ]; then - if [ ! -d /usr/openwin ]; then - echo "openwin: /usr/openwin does not exist, cannot start" + if [ ! -d /usr ]; then + echo "openwin: /usr does not exist, cannot start" exit 1 fi - OPENWINHOME=/usr/openwin + OPENWINHOME=/usr fi if [ -z "$X11HOME" ]; then @@ -46,10 +46,10 @@ if [ "$XDM" = "running" ]; then # X is already running (e.g. this file was called from xdm) # so just run openwin's Xinitrc - exec $OPENWINHOME/lib/Xinitrc + exec /etc/openwin/Xinitrc else if [ -x $X11HOME/bin/startx ]; then - exec $X11HOME/bin/startx $OPENWINHOME/lib/Xinitrc -- + exec $X11HOME/bin/startx /etc/openwin/Xinitrc -- fi - exec startx $OPENWINHOME/lib/Xinitrc -- + exec startx /etc/openwin//Xinitrc -- fi diff -rNu xview-3.2p1.4-old/imake xview-3.2p1.4/imake --- xview-3.2p1.4-old/imake 2013-08-28 17:12:56.436682003 +0200 +++ xview-3.2p1.4/imake 2013-08-28 17:13:08.940682186 +0200 @@ -2,8 +2,17 @@ set -e +IFS=', ' read -a output <<< `whereis -b imake` +IMAKE="${output[1]}" + +if [ -z "$IMAKE" ]; then + echo "imake not found!" 1>&2 + exit 1 +fi + echo "imake-wrapper: running imake $* in directory `pwd`" -/usr/bin/X11/imake "$@" + +$IMAKE "$@" if [ -f "$IMAKEAPPEND" ]; then cat "$IMAKEAPPEND" >> Makefile fi diff -rNu xview-3.2p1.4-old/lib/libxview/textsw/txt_e_menu.c xview-3.2p1.4/lib/libxview/textsw/txt_e_menu.c --- xview-3.2p1.4-old/lib/libxview/textsw/txt_e_menu.c 2013-08-28 17:12:56.380682002 +0200 +++ xview-3.2p1.4/lib/libxview/textsw/txt_e_menu.c 2013-08-28 17:13:08.944682186 +0200 @@ -160,6 +160,10 @@ #ifndef OPENWINHOME_DEFAULT } #endif + + (void) sprintf(tmp, "/etc/openwin/%s", EXTRASMENU); + if ((result = check_filename_locale(NULL, tmp, 1)) != NULL) + goto found; /* Giving up, try with ancient way (SunView1) */ (void) sprintf(tmp, "/usr/lib/.%s", EXTRASMENU); diff -rNu xview-3.2p1.4-old/lib/libxview/ttysw/tty_mapkey.c xview-3.2p1.4/lib/libxview/ttysw/tty_mapkey.c --- xview-3.2p1.4-old/lib/libxview/ttysw/tty_mapkey.c 2013-08-28 17:12:56.372682002 +0200 +++ xview-3.2p1.4/lib/libxview/ttysw/tty_mapkey.c 2013-08-28 17:13:08.944682186 +0200 @@ -76,6 +76,9 @@ char *altrc; XV_BZERO(rc, 1024); + if (!access("/etc/openwin/ttyswrc", R_OK)) { + (void)strcpy(rc, "/etc/openwin/ttyswrc"); + } else #if 1 /* FHS compliance - mbuck@debian.org */ if (!access("/etc/X11/xview/ttyswrc", R_OK)) { (void)strcpy(rc, "/etc/X11/xview/ttyswrc"); diff -rNu xview-3.2p1.4-old/misc/support/Imakefile xview-3.2p1.4/misc/support/Imakefile --- xview-3.2p1.4-old/misc/support/Imakefile 2013-08-28 17:12:56.312682001 +0200 +++ xview-3.2p1.4/misc/support/Imakefile 2013-08-28 17:13:08.944682186 +0200 @@ -15,7 +15,7 @@ install:: $(MKDIRHIER) $(DESTDIR)$(HELP_DEST) $(DESTDIR)$(LIBRARY_DEST) -InstallSupportList($(SUPPORTFILES),$(LIBRARY_DEST)) +InstallSupportList($(SUPPORTFILES),$(ETCDEST)) InstallNonExecList($(INFOFILES),$(HELP_DEST)) DependTarget() LintTarget() diff -rNu xview-3.2p1.4-old/util/conversion/cv2xview xview-3.2p1.4/util/conversion/cv2xview --- xview-3.2p1.4-old/util/conversion/cv2xview 2013-08-28 17:12:56.312682001 +0200 +++ xview-3.2p1.4/util/conversion/cv2xview 2013-08-28 17:50:42.568715237 +0200 @@ -12,12 +12,18 @@ # # Produces a new XView source files for each filename # +if [ `uname -m` == 'x86_64' ]; then + __LIB__=lib64 +else + __LIB__=lib +fi + USAGE="Usage: `basename ${0}` [-m] filename..." CONV_TYPE=full MIN_CONV_TYPE=minimal CTXV_ROOT= -XVIEW_BINS=lib/xview/ +XVIEW_BINS=$__LIB__/xview/ #XVIEW_BINS=bin/xview/ [ -z "$OPENWINHOME" ] && OPENWINHOME=/usr/openwin diff -rNu xview-3.2p1.4-old/util/msgfmt/Imakefile xview-3.2p1.4/util/msgfmt/Imakefile --- xview-3.2p1.4-old/util/msgfmt/Imakefile 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/util/msgfmt/Imakefile 2013-08-28 17:13:08.944682186 +0200 @@ -4,4 +4,4 @@ #include <XView.tmpl> MANSUFFIX =1 -SimpleProgramTarget(msgfmt) +SimpleProgramTarget(msgfmt_xv) diff -rNu xview-3.2p1.4-old/util/msgfmt/msgfmt.c xview-3.2p1.4/util/msgfmt/msgfmt.c --- xview-3.2p1.4-old/util/msgfmt/msgfmt.c 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/util/msgfmt/msgfmt.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,669 +0,0 @@ -#ifndef lint -#ifdef sccs -static char sccsid[] = "@(#)msgfmt.c 1.3 91/09/14"; -#endif -#endif - -#include "msgfmt.h" - -/* - * msgfmt - Generate binary tree for runtime gettext() using psffm: - * "Portable Source File Format for Messages" file template. - * This file may have previously been generated by the - * c2psffm filter for c source files. - */ - -#define ignore(a) ((void) a) - -char *consume_whitespace(); -char expand_meta(); -char *calloc(); -off_t tellpt; -off_t sortit(); -char *mktemp(); -char *savestr(); -char *strcat(); -char *strcpy(); - -off_t mesgpt; - -/* - * Strings is a flat file of id, string pairs, used by cflg - */ - -char *strings = "strings"; - -char linebuf[MAX_VALUE_LEN]; -char *domain_name = DEFAULT_DOMAIN; - -int cflg = 0; -int verbose = 0; -int debug = 0; -int readstd; - -struct list_struct list; - -main(argc, argv) - int argc; - char *argv[]; -{ - - argc--, argv++; - while (argc > 0 && argv[0][0] == '-') { - - register char *cp = &(*argv++)[1]; - - argc--; - - if (*cp == 0) { - readstd++; - } - - do switch (*cp++) { - -/* - * cflag stuff not yet implemented. - - case 'c': - cflg++; - continue; - */ - - case 'd': - debug++; - break; - - case 'v': - verbose++; - continue; - - default: -/* - fprintf(stderr, - "usage: msgfmt [ -v ] [ -c ] [ - ] [ name ... ]\n"); -*/ - fprintf(stderr, - "usage: msgfmt [ -dv ] [ - ] [ name ... ]\n"); - break;; - - } while (*cp); /* do switch ... */ - - } /* while (argc ... */ - - - while (readstd || argc > 0) { - - if (!readstd && freopen(argv[0], "r", stdin) == NULL) { - perror(argv[0]); - exit(2); - } - - read_psffm(argv[0]); - - if (readstd == 0) { - argc--; argv++; - } else { - readstd = 0; - } - } /* while (readstd ... */ - - exit(0); -} - - -/* - * read_psffm - read in "psffm" format file, check syntax, printing - * error messages as needed, output binary tree to - * file <domain> -*/ - -read_psffm(filename) - char *filename; -{ - - static char current_domain[MAX_DOMAIN_LENGTH]; - static char msgfile[MAXPATHLEN]; - - - char *linebufptr; - char *current_locale; - char msgid [MAX_VALUE_LEN+1]; - char msgstr [MAX_VALUE_LEN+1]; - register char *bufptr; - - - int linenum = 0; - int domain_set = 0; - int whitespace = 0; - int quotefound = 0; - int ignored = 0; - int indomain = 0; - int inmsgid = 0; - int inmsgstr = 0; - char c; - - - while (1) { - memset(linebuf, 0, sizeof(linebuf)); - if (fgets(linebuf, sizeof(linebuf), stdin) == NULL) { - if (ferror(stdin)) { - perror(filename); - exit(2); - } - break; - } - linenum ++; - - if (verbose) { - printf("Scanning line number %d: %s\n", linenum, linebuf); - } - - linebufptr = linebuf; - whitespace = 0; - - switch (*linebufptr) { - case '#': /* comment */ - case '\n': - ignored = 1; - break; - - case '\"': - case ' ': /* whitespace should be handled correctly */ - case '\t': - whitespace = 1; - default: - ignored = 0; - break; - } - - if (ignored) { - continue; - } - - /* - * Process MSGID Tokens, must not have just seen one unless - * this line begins with whitespace -or- " - */ - - if ((!strncmp(MSGID_TOKEN, linebuf, sizeof(MSGID_TOKEN)-1)) - || (whitespace && inmsgid)) { - if (inmsgid && !whitespace) { - fprintf(stderr, "Consecutive MSGID tokens encountered "); - fprintf(stderr, "at line number: %d, exiting\n", linenum); -/* - exit(1); -*/ - } - if (inmsgstr) { - sortit(msgid, msgstr, 1); - - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - } - - - if (inmsgid) { - linebufptr = consume_whitespace(linebuf); - } else { - linebufptr = consume_whitespace(linebuf + - sizeof(MSGID_TOKEN)-1); - bufptr = msgid; - } - - inmsgid = 1; - inmsgstr = 0; - indomain = 0; - goto load_buffer; - } - - /* - * Process MSGSTR Tokens, must not have just seen one unless - * this line begins with whitespace -or- " - */ - - if ((!strncmp(MSGSTR_TOKEN, linebuf, sizeof(MSGSTR_TOKEN)-1)) - || (whitespace && inmsgstr)) { - if (inmsgstr && !whitespace) { - fprintf(stderr, "Consecutive MSGSTR tokens encountered "); - fprintf(stderr, "at line number: %d, exiting\n", linenum); -/* - exit(1); -*/ - } - - if (inmsgstr) { - linebufptr = consume_whitespace(linebuf); - } else { - linebufptr = consume_whitespace(linebuf + - sizeof(MSGSTR_TOKEN)-1); - bufptr = msgstr; - } - - inmsgstr = 1; - inmsgid = 0; - indomain = 0; - goto load_buffer; - } - - /* - * Process DOMAIN Tokens, add message id and message string to - * sorted list if msgstr was being processed, - * write out file for existing domain if it exists (domain_set = 1) - */ - - if (!strncmp(DOMAIN_TOKEN, linebuf, sizeof(DOMAIN_TOKEN)-1)) { - if (inmsgstr) { - sortit(msgid, msgstr, 1); - } - - if (inmsgstr || inmsgid) { - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - } - - if (domain_set) { - output_file(msgfile); - } - domain_set = 1; - indomain = 1; - inmsgid = 0; - inmsgstr = 0; - - linebufptr = consume_whitespace(linebuf+ sizeof(DOMAIN_TOKEN)); - memset(current_domain, 0, sizeof(current_domain)); - bufptr = current_domain; - } - -load_buffer: - - if (*linebufptr++ != '\"') { - fprintf(stderr, "Warning, Syntax at line number: %d, ", - linenum); - fprintf(stderr, "Missing \", ignored\n"); - --linebufptr; - } - - quotefound = 0; - - while (c=*linebufptr++) { - switch (c) { - case '\n': - if (!quotefound) { - fprintf(stderr, "Warning, Syntax at line number: %d, ", - linenum); - fprintf(stderr, "Missing \" at EOL, ignored\n"); - } - break; - - case '\"': - quotefound = 1; - break; - - case '\\': - *bufptr++ = expand_meta(&linebufptr); - break; - - default: - *bufptr++ = c; - } - } - - if (indomain) { - memset(msgfile, 0, sizeof(msgfile)); - strcpy(msgfile, current_domain); - strcat(msgfile, ".mo"); -/* - strcpy(msgfile, LOCALEDIR); - strcat(msgfile, current_locale); - strcat(msgfile, "/"); - strcat(msgfile, current_domain); -*/ - } - } - - if (inmsgstr) { - sortit(msgid, msgstr, 1); - } - - if (inmsgstr || inmsgid) { - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - } - - if (domain_set) { - output_file(msgfile); - } - return(0); -} - - -char * -consume_whitespace(buf) - char *buf; -{ - register char *bufptr = buf; - char c; - while (c = *bufptr++) { - switch (c) { - case ' ': - case '\t' : - continue; - default: - return(bufptr-1); - } - } -} - -char -expand_meta(buf) - char **buf; -{ - register char c = **buf; - - switch (c) { - case '"': - (*buf)++; - return ('\"'); - case '\\': - (*buf)++; - return ('\\'); - case 'b' : - (*buf)++; - return ('\b'); - case 'f' : - (*buf)++; - return ('\f'); - case 'n' : - (*buf)++; - return ('\n'); - case 'r' : - (*buf)++; - return ('\r'); - case 't' : - (*buf)++; - return ('\t'); - case 'v' : - (*buf)++; - return ('\v'); - default: - return ('\\'); - } -} - - - -/* - * sortit - insertion sort, place message identifier = str and - * message string = msgstr into list sorted by message identifier -*/ - -off_t -sortit(msgid, msgstr, new) - char *msgid, *msgstr; - int new; -{ - int i, j, lessthan; - register struct list_struct *hp, *hp0, *hp1; - - if (debug) - fprintf(stderr, - "==> sortit(), msgid = %s, msgstr = %s\n", msgid, msgstr); - lessthan = 0; - hp = hp0 = &list; - while (hp->hnext && !lessthan) { - hp0 = hp; - hp = hp->hnext; - i = istail(hp->msgid, msgid); - if (i < 0) { - lessthan = 1; - hp1 = hp; - continue; - } - if (i == 0) { /* found! */ - return(hp->hpt); - } - } - if (!lessthan) { - hp0 = hp; - } - if ((hp = (struct list_struct *) calloc(1, sizeof(*hp))) == NULL) { - perror("msgfmt"); - exit(8); - } - hp->hpt = mesgpt; - hp->msgid = savestr(msgid); - hp->msg = savestr(msgstr); - mesgpt += strlen(hp->msgid) + strlen(hp->msg); - - if (hp0->hnext) { - hp->hnext = hp1; - hp0->hnext = hp; - hp->hnew = new; - } else { - hp->hnew = new; - hp0->hnext = hp; - } - return(hp->hpt); -} - -printlist() -{ - struct list_struct *hp1; - - hp1 = &list; - fprintf(stderr, "dumping record at offset hpt = %d\n", hp1->hpt); - fprintf(stderr, "message id is %s\n", hp1->msgid); - fprintf(stderr, "message string is %s\n", hp1->msg); - - while (hp1->hnext) { - fprintf(stderr, "dumping record at offset hpt = %d\n", hp1->hpt); - fprintf(stderr, "message id is %s\n", hp1->hnext->msgid); - fprintf(stderr, "message string is %s\n", hp1->hnext->msg); - hp1 = hp1->hnext; - } - -} - - -/* - * binary_compute is used for pre-computing a binary search. - */ -int -binary_compute(i, j, more, less) - int i,j; - int more[],less[]; -{ - int k; - - if (i > j ) { - return -99; - } - k = (i + j)/2; - - less[k] = binary_compute(i, k-1, more, less); - more[k] = binary_compute(k+1, j, more, less); - return k; -} - -/* - * Write out static_message File contains static structure of messages. - */ -#ifdef USE_MMAP -output_file(file) - char *file; -{ - FILE *xdotcf = fopen(file, "w"); - struct list_struct *lp; - int message_count; - int string_count_msgid=0; - int string_count_msg=0; - int msgid_index=0; - int msg_index=0; - int *less,*more; - int i; - - if (xdotcf == NULL) { - perror("static_messages"); - exit(6); - } - - message_count = 0; - lp = &list; - while (lp->hnext) { /* get offsets and counts */ - lp->hnext->msgid_offset = msgid_index; - lp->hnext->msg_offset = msg_index; - msgid_index += strlen(lp->hnext->msgid)+1; - msg_index += strlen(lp->hnext->msg)+1; - message_count++; - lp = lp->hnext; - } - string_count_msgid = msgid_index; - string_count_msg = msg_index; - if ((less = (int *) calloc(message_count, sizeof(int))) == NULL) { - perror("msgfmt output_file()"); - exit(8); - } - if ((more = (int *) calloc(message_count, sizeof(int))) == NULL) { - perror("msgfmt output_file()"); - exit(8); - } - (void) binary_compute(0, message_count-1, more, less); - if (message_count == 2) { - less[1] = -99; /* kludge that works! */ - } - - /* write out the message.mo */ - i = (message_count-1)/2; /* this is the first message to check */ - (void) fwrite(&i, sizeof(int), 1, xdotcf); - (void) fwrite(&message_count, sizeof(int), 1, xdotcf); - (void) fwrite(&string_count_msgid, sizeof(int), 1, xdotcf); - (void) fwrite(&string_count_msg, sizeof(int), 1, xdotcf); - i = sizeof(struct list_struct) * message_count; - (void) fwrite(&i, sizeof(int), 1, xdotcf); - i = 0; /* used to get more and less */ - lp = &list; - while (lp->hnext) { /* put out message struct */ - (void) fwrite(&less[i], sizeof(int), 1, xdotcf); - (void) fwrite(&more[i], sizeof(int), 1, xdotcf); - (void) fwrite(&lp->hnext->msgid_offset, sizeof(int), 1, xdotcf); - (void) fwrite(&lp->hnext->msg_offset, sizeof(int), 1, xdotcf); - i++; - lp = lp->hnext; - } - lp = &list; - while (lp->hnext) { /* put out messageid strings */ - (void) fwrite(lp->hnext->msgid, strlen(lp->hnext->msgid)+1, 1, xdotcf); - lp = lp->hnext; - } - lp = &list; - while (lp->hnext) { /* put out message strings */ - (void) fwrite(lp->hnext->msg, strlen(lp->hnext->msg)+1, 1, xdotcf); - lp = lp->hnext; - } - ignore(fclose(xdotcf)); - /* clear list */ - list.hpt =0; - list.msgid_offset =0; - list.msg_offset =0; - list.msgid =(char )0; - list.msg =(char )0; - list.hnext = NULL; - list.hnew = 0; -} - -#else - - -output_file(file) - char *file; -{ - FILE *xdotcf = fopen(file, "w"); - struct list_struct *lp; - int message_count; - int *less, *more; - int i; - - if (xdotcf == NULL){ - perror(file); - exit(6); - } - - message_count = 0; - lp = &list; - while (lp->hnext) { - message_count++; - lp = lp->hnext; - } - if ((less = (int *) calloc(message_count, sizeof(int))) == NULL) { - perror("msgfmt output_file()"); - exit(8); - } - if ((more = (int *) calloc(message_count, sizeof(int))) == NULL) { - perror("msgfmt output_file()"); - exit(8); - } - binary_compute(0, message_count-1, more, less); - if (message_count == 2) { - less[1] = 0; /* kludge that works! */ - } - - - - /* put out messages in binary format */ - - fprintf(xdotcf,"%d\n%d\n", message_count, (message_count-1)/2); - lp = &list; - while (lp->hnext) { - fprintf(xdotcf,"%s\n", lp->hnext->msgid); /* message id */ - fprintf(xdotcf,"%d\n%d\n", *less++, *more++); - fprintf(xdotcf,"%s\n", lp->hnext->msg); /* message id */ - lp = lp->hnext; - } - ignore(fclose(xdotcf)); - - freelist(); -} -#endif - -/* - * freelist() - frees all members of the sorted list after the list - * is written out to the binary tree file, called when - * changing domains and when exiting the program -*/ - -freelist() -{ - register struct list_struct *hp, *hp0; - - hp0 = &list; - hp = hp0->hnext; - - while (hp->hnext) { - hp0 = hp; - hp = hp->hnext; - free(hp0); - } - free(hp); - list.hnext = 0; -} - -char * -savestr(cp) - register char *cp; -{ - register char *dp; - - if ((dp = (char *) calloc(1, strlen(cp) + 1)) == NULL) { - perror("msgfmt"); - exit(8); - } - return(strcpy(dp, cp)); -} - - -istail(str, of) - register char *str, *of; -{ - - return(strcmp(of, str)); -} diff -rNu xview-3.2p1.4-old/util/msgfmt/msgfmt.man xview-3.2p1.4/util/msgfmt/msgfmt.man --- xview-3.2p1.4-old/util/msgfmt/msgfmt.man 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/util/msgfmt/msgfmt.man 1970-01-01 01:00:00.000000000 +0100 @@ -1,161 +0,0 @@ -.\" @(#)msgfmt.1 1.6 90/10/12 SMI; from Sun -.TH msgfmt 1 "25 July 1990" -.SH NAME -msgfmt \- create a message object from a message file -.SH SYNOPSIS -.B msgfmt -[ -.B \-v -] -.I filename\c -.B \&.po -\&.\|.\|. -.IX "msgfmt" "" "\fLmsgfmt\fP \(em create message object file" -.IX "messages" "create message object file" -.SH DESCRIPTION -.LP -.B msgfmt -creates a -message object -.I filename -.B \&.mo -file from the portable message file -.I filename\c -.BR \&.po . -.LP -The -.B .po -file contains strings extracted from source code. -.B .po -files can be edited, and the -messages in them can changed to accomodate -any language supported by the system. -.LP -The -.B xgettext -command (see -.BR xgettext (1)) -can be used to create the -.B default.po -file. -.LP -The -.B msgfmt -command does not modify the -portable object files. -.SS "Portable Object Files" -.IX "messages" "creating portable object files" -.IX "messages" "editing messages" -.IX "\&.po files" "portable object files" -.IX "\&.mo files" "message object files" -.LP -Each -.B .po -file contains one or more lines. -Each line -contains either a comment or a statement. -Comments start the line with a hash mark (#) and end with -the newline character and are ignored. -.LP -Each directive starts on a new line and is -separated from -.BI < value > -by white space (such as one or more space or tab characters). -.BI < value > -consists of one or more quoted strings separated by white space or <CR>. -The following are valid directives: -.IX "messages" "setting the domain" -.IX "messages" "setting the message identifier" -.IX "messages" "setting the message string" -.RS -.B domain -.I domainname -.br -.B msgid -.I message_identifier -.br -.B msgstr -.I message_string -.RE -.LP -The -.B domain -directive identifies all following directives until -another -.B domain -directive is encountered as applying to the domain -.I domainname. -The -.I domainname -is a string up to -.SM MAXDOMAIN -bytes long, and can contain any characters -allowed in legal filenames. -Until the first -.B domain -directive is encountered in the file, all target strings -belong to the default domain. -The default domain is called -.BR default . -.LP -The -.B msgid -directive specifies the message identifier for the following -.B msgstr directive. -The -.I message_identifier -string identifies a target string at retrieval time. -Every statement containing a -.B msgid -directive must be followed by a statement containing a -.B msgstr -directive. -.LP -The -.B msgstr -directive specifies the target string associated with the -.I message_identifier -string declared in the immediately preceding -.B msgid -directive. -.SH OPTIONS -.TP 10 -.B \-v -Verbose. List duplicate message identifiers. -Message strings are not redefined. -.SH EXAMPLES -.LP -The following command creates a named -.B " .mo" -file for each domain named in the portable message objects -.BR " filename1.po " and " filename2.po" . -.LP -.RS -.nf -.B msgfmt filename1.po filename2.po -.RE -.fi -.LP -Running -.BR msgfmt (1) -on the following sample -.B .po -file creates two -.B .mo -files, named -.B first.mo -and -.B second.mo. -.RS -.nf -domain "first.mo" -msgid "aao" -msgstr "first sample message" -domain "second.mo" -msgid "bbo" -msgstr "second sample message" -.RE -.fi -.SH "SEE ALSO" -.BR xgettext (1) , -.BR gettext (3) . diff -rNu xview-3.2p1.4-old/util/msgfmt/msgfmt_xv.c xview-3.2p1.4/util/msgfmt/msgfmt_xv.c --- xview-3.2p1.4-old/util/msgfmt/msgfmt_xv.c 1970-01-01 01:00:00.000000000 +0100 +++ xview-3.2p1.4/util/msgfmt/msgfmt_xv.c 2013-08-28 17:13:08.948682186 +0200 @@ -0,0 +1,669 @@ +#ifndef lint +#ifdef sccs +static char sccsid[] = "@(#)msgfmt.c 1.3 91/09/14"; +#endif +#endif + +#include "msgfmt.h" + +/* + * msgfmt - Generate binary tree for runtime gettext() using psffm: + * "Portable Source File Format for Messages" file template. + * This file may have previously been generated by the + * c2psffm filter for c source files. + */ + +#define ignore(a) ((void) a) + +char *consume_whitespace(); +char expand_meta(); +char *calloc(); +off_t tellpt; +off_t sortit(); +char *mktemp(); +char *savestr(); +char *strcat(); +char *strcpy(); + +off_t mesgpt; + +/* + * Strings is a flat file of id, string pairs, used by cflg + */ + +char *strings = "strings"; + +char linebuf[MAX_VALUE_LEN]; +char *domain_name = DEFAULT_DOMAIN; + +int cflg = 0; +int verbose = 0; +int debug = 0; +int readstd; + +struct list_struct list; + +main(argc, argv) + int argc; + char *argv[]; +{ + + argc--, argv++; + while (argc > 0 && argv[0][0] == '-') { + + register char *cp = &(*argv++)[1]; + + argc--; + + if (*cp == 0) { + readstd++; + } + + do switch (*cp++) { + +/* + * cflag stuff not yet implemented. + + case 'c': + cflg++; + continue; + */ + + case 'd': + debug++; + break; + + case 'v': + verbose++; + continue; + + default: +/* + fprintf(stderr, + "usage: msgfmt [ -v ] [ -c ] [ - ] [ name ... ]\n"); +*/ + fprintf(stderr, + "usage: msgfmt [ -dv ] [ - ] [ name ... ]\n"); + break;; + + } while (*cp); /* do switch ... */ + + } /* while (argc ... */ + + + while (readstd || argc > 0) { + + if (!readstd && freopen(argv[0], "r", stdin) == NULL) { + perror(argv[0]); + exit(2); + } + + read_psffm(argv[0]); + + if (readstd == 0) { + argc--; argv++; + } else { + readstd = 0; + } + } /* while (readstd ... */ + + exit(0); +} + + +/* + * read_psffm - read in "psffm" format file, check syntax, printing + * error messages as needed, output binary tree to + * file <domain> +*/ + +read_psffm(filename) + char *filename; +{ + + static char current_domain[MAX_DOMAIN_LENGTH]; + static char msgfile[MAXPATHLEN]; + + + char *linebufptr; + char *current_locale; + char msgid [MAX_VALUE_LEN+1]; + char msgstr [MAX_VALUE_LEN+1]; + register char *bufptr; + + + int linenum = 0; + int domain_set = 0; + int whitespace = 0; + int quotefound = 0; + int ignored = 0; + int indomain = 0; + int inmsgid = 0; + int inmsgstr = 0; + char c; + + + while (1) { + memset(linebuf, 0, sizeof(linebuf)); + if (fgets(linebuf, sizeof(linebuf), stdin) == NULL) { + if (ferror(stdin)) { + perror(filename); + exit(2); + } + break; + } + linenum ++; + + if (verbose) { + printf("Scanning line number %d: %s\n", linenum, linebuf); + } + + linebufptr = linebuf; + whitespace = 0; + + switch (*linebufptr) { + case '#': /* comment */ + case '\n': + ignored = 1; + break; + + case '\"': + case ' ': /* whitespace should be handled correctly */ + case '\t': + whitespace = 1; + default: + ignored = 0; + break; + } + + if (ignored) { + continue; + } + + /* + * Process MSGID Tokens, must not have just seen one unless + * this line begins with whitespace -or- " + */ + + if ((!strncmp(MSGID_TOKEN, linebuf, sizeof(MSGID_TOKEN)-1)) + || (whitespace && inmsgid)) { + if (inmsgid && !whitespace) { + fprintf(stderr, "Consecutive MSGID tokens encountered "); + fprintf(stderr, "at line number: %d, exiting\n", linenum); +/* + exit(1); +*/ + } + if (inmsgstr) { + sortit(msgid, msgstr, 1); + + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + } + + + if (inmsgid) { + linebufptr = consume_whitespace(linebuf); + } else { + linebufptr = consume_whitespace(linebuf + + sizeof(MSGID_TOKEN)-1); + bufptr = msgid; + } + + inmsgid = 1; + inmsgstr = 0; + indomain = 0; + goto load_buffer; + } + + /* + * Process MSGSTR Tokens, must not have just seen one unless + * this line begins with whitespace -or- " + */ + + if ((!strncmp(MSGSTR_TOKEN, linebuf, sizeof(MSGSTR_TOKEN)-1)) + || (whitespace && inmsgstr)) { + if (inmsgstr && !whitespace) { + fprintf(stderr, "Consecutive MSGSTR tokens encountered "); + fprintf(stderr, "at line number: %d, exiting\n", linenum); +/* + exit(1); +*/ + } + + if (inmsgstr) { + linebufptr = consume_whitespace(linebuf); + } else { + linebufptr = consume_whitespace(linebuf + + sizeof(MSGSTR_TOKEN)-1); + bufptr = msgstr; + } + + inmsgstr = 1; + inmsgid = 0; + indomain = 0; + goto load_buffer; + } + + /* + * Process DOMAIN Tokens, add message id and message string to + * sorted list if msgstr was being processed, + * write out file for existing domain if it exists (domain_set = 1) + */ + + if (!strncmp(DOMAIN_TOKEN, linebuf, sizeof(DOMAIN_TOKEN)-1)) { + if (inmsgstr) { + sortit(msgid, msgstr, 1); + } + + if (inmsgstr || inmsgid) { + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + } + + if (domain_set) { + output_file(msgfile); + } + domain_set = 1; + indomain = 1; + inmsgid = 0; + inmsgstr = 0; + + linebufptr = consume_whitespace(linebuf+ sizeof(DOMAIN_TOKEN)); + memset(current_domain, 0, sizeof(current_domain)); + bufptr = current_domain; + } + +load_buffer: + + if (*linebufptr++ != '\"') { + fprintf(stderr, "Warning, Syntax at line number: %d, ", + linenum); + fprintf(stderr, "Missing \", ignored\n"); + --linebufptr; + } + + quotefound = 0; + + while (c=*linebufptr++) { + switch (c) { + case '\n': + if (!quotefound) { + fprintf(stderr, "Warning, Syntax at line number: %d, ", + linenum); + fprintf(stderr, "Missing \" at EOL, ignored\n"); + } + break; + + case '\"': + quotefound = 1; + break; + + case '\\': + *bufptr++ = expand_meta(&linebufptr); + break; + + default: + *bufptr++ = c; + } + } + + if (indomain) { + memset(msgfile, 0, sizeof(msgfile)); + strcpy(msgfile, current_domain); + strcat(msgfile, ".mo"); +/* + strcpy(msgfile, LOCALEDIR); + strcat(msgfile, current_locale); + strcat(msgfile, "/"); + strcat(msgfile, current_domain); +*/ + } + } + + if (inmsgstr) { + sortit(msgid, msgstr, 1); + } + + if (inmsgstr || inmsgid) { + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + } + + if (domain_set) { + output_file(msgfile); + } + return(0); +} + + +char * +consume_whitespace(buf) + char *buf; +{ + register char *bufptr = buf; + char c; + while (c = *bufptr++) { + switch (c) { + case ' ': + case '\t' : + continue; + default: + return(bufptr-1); + } + } +} + +char +expand_meta(buf) + char **buf; +{ + register char c = **buf; + + switch (c) { + case '"': + (*buf)++; + return ('\"'); + case '\\': + (*buf)++; + return ('\\'); + case 'b' : + (*buf)++; + return ('\b'); + case 'f' : + (*buf)++; + return ('\f'); + case 'n' : + (*buf)++; + return ('\n'); + case 'r' : + (*buf)++; + return ('\r'); + case 't' : + (*buf)++; + return ('\t'); + case 'v' : + (*buf)++; + return ('\v'); + default: + return ('\\'); + } +} + + + +/* + * sortit - insertion sort, place message identifier = str and + * message string = msgstr into list sorted by message identifier +*/ + +off_t +sortit(msgid, msgstr, new) + char *msgid, *msgstr; + int new; +{ + int i, j, lessthan; + register struct list_struct *hp, *hp0, *hp1; + + if (debug) + fprintf(stderr, + "==> sortit(), msgid = %s, msgstr = %s\n", msgid, msgstr); + lessthan = 0; + hp = hp0 = &list; + while (hp->hnext && !lessthan) { + hp0 = hp; + hp = hp->hnext; + i = istail(hp->msgid, msgid); + if (i < 0) { + lessthan = 1; + hp1 = hp; + continue; + } + if (i == 0) { /* found! */ + return(hp->hpt); + } + } + if (!lessthan) { + hp0 = hp; + } + if ((hp = (struct list_struct *) calloc(1, sizeof(*hp))) == NULL) { + perror("msgfmt"); + exit(8); + } + hp->hpt = mesgpt; + hp->msgid = savestr(msgid); + hp->msg = savestr(msgstr); + mesgpt += strlen(hp->msgid) + strlen(hp->msg); + + if (hp0->hnext) { + hp->hnext = hp1; + hp0->hnext = hp; + hp->hnew = new; + } else { + hp->hnew = new; + hp0->hnext = hp; + } + return(hp->hpt); +} + +printlist() +{ + struct list_struct *hp1; + + hp1 = &list; + fprintf(stderr, "dumping record at offset hpt = %d\n", hp1->hpt); + fprintf(stderr, "message id is %s\n", hp1->msgid); + fprintf(stderr, "message string is %s\n", hp1->msg); + + while (hp1->hnext) { + fprintf(stderr, "dumping record at offset hpt = %d\n", hp1->hpt); + fprintf(stderr, "message id is %s\n", hp1->hnext->msgid); + fprintf(stderr, "message string is %s\n", hp1->hnext->msg); + hp1 = hp1->hnext; + } + +} + + +/* + * binary_compute is used for pre-computing a binary search. + */ +int +binary_compute(i, j, more, less) + int i,j; + int more[],less[]; +{ + int k; + + if (i > j ) { + return -99; + } + k = (i + j)/2; + + less[k] = binary_compute(i, k-1, more, less); + more[k] = binary_compute(k+1, j, more, less); + return k; +} + +/* + * Write out static_message File contains static structure of messages. + */ +#ifdef USE_MMAP +output_file(file) + char *file; +{ + FILE *xdotcf = fopen(file, "w"); + struct list_struct *lp; + int message_count; + int string_count_msgid=0; + int string_count_msg=0; + int msgid_index=0; + int msg_index=0; + int *less,*more; + int i; + + if (xdotcf == NULL) { + perror("static_messages"); + exit(6); + } + + message_count = 0; + lp = &list; + while (lp->hnext) { /* get offsets and counts */ + lp->hnext->msgid_offset = msgid_index; + lp->hnext->msg_offset = msg_index; + msgid_index += strlen(lp->hnext->msgid)+1; + msg_index += strlen(lp->hnext->msg)+1; + message_count++; + lp = lp->hnext; + } + string_count_msgid = msgid_index; + string_count_msg = msg_index; + if ((less = (int *) calloc(message_count, sizeof(int))) == NULL) { + perror("msgfmt output_file()"); + exit(8); + } + if ((more = (int *) calloc(message_count, sizeof(int))) == NULL) { + perror("msgfmt output_file()"); + exit(8); + } + (void) binary_compute(0, message_count-1, more, less); + if (message_count == 2) { + less[1] = -99; /* kludge that works! */ + } + + /* write out the message.mo */ + i = (message_count-1)/2; /* this is the first message to check */ + (void) fwrite(&i, sizeof(int), 1, xdotcf); + (void) fwrite(&message_count, sizeof(int), 1, xdotcf); + (void) fwrite(&string_count_msgid, sizeof(int), 1, xdotcf); + (void) fwrite(&string_count_msg, sizeof(int), 1, xdotcf); + i = sizeof(struct list_struct) * message_count; + (void) fwrite(&i, sizeof(int), 1, xdotcf); + i = 0; /* used to get more and less */ + lp = &list; + while (lp->hnext) { /* put out message struct */ + (void) fwrite(&less[i], sizeof(int), 1, xdotcf); + (void) fwrite(&more[i], sizeof(int), 1, xdotcf); + (void) fwrite(&lp->hnext->msgid_offset, sizeof(int), 1, xdotcf); + (void) fwrite(&lp->hnext->msg_offset, sizeof(int), 1, xdotcf); + i++; + lp = lp->hnext; + } + lp = &list; + while (lp->hnext) { /* put out messageid strings */ + (void) fwrite(lp->hnext->msgid, strlen(lp->hnext->msgid)+1, 1, xdotcf); + lp = lp->hnext; + } + lp = &list; + while (lp->hnext) { /* put out message strings */ + (void) fwrite(lp->hnext->msg, strlen(lp->hnext->msg)+1, 1, xdotcf); + lp = lp->hnext; + } + ignore(fclose(xdotcf)); + /* clear list */ + list.hpt =0; + list.msgid_offset =0; + list.msg_offset =0; + list.msgid =(char )0; + list.msg =(char )0; + list.hnext = NULL; + list.hnew = 0; +} + +#else + + +output_file(file) + char *file; +{ + FILE *xdotcf = fopen(file, "w"); + struct list_struct *lp; + int message_count; + int *less, *more; + int i; + + if (xdotcf == NULL){ + perror(file); + exit(6); + } + + message_count = 0; + lp = &list; + while (lp->hnext) { + message_count++; + lp = lp->hnext; + } + if ((less = (int *) calloc(message_count, sizeof(int))) == NULL) { + perror("msgfmt output_file()"); + exit(8); + } + if ((more = (int *) calloc(message_count, sizeof(int))) == NULL) { + perror("msgfmt output_file()"); + exit(8); + } + binary_compute(0, message_count-1, more, less); + if (message_count == 2) { + less[1] = 0; /* kludge that works! */ + } + + + + /* put out messages in binary format */ + + fprintf(xdotcf,"%d\n%d\n", message_count, (message_count-1)/2); + lp = &list; + while (lp->hnext) { + fprintf(xdotcf,"%s\n", lp->hnext->msgid); /* message id */ + fprintf(xdotcf,"%d\n%d\n", *less++, *more++); + fprintf(xdotcf,"%s\n", lp->hnext->msg); /* message id */ + lp = lp->hnext; + } + ignore(fclose(xdotcf)); + + freelist(); +} +#endif + +/* + * freelist() - frees all members of the sorted list after the list + * is written out to the binary tree file, called when + * changing domains and when exiting the program +*/ + +freelist() +{ + register struct list_struct *hp, *hp0; + + hp0 = &list; + hp = hp0->hnext; + + while (hp->hnext) { + hp0 = hp; + hp = hp->hnext; + free(hp0); + } + free(hp); + list.hnext = 0; +} + +char * +savestr(cp) + register char *cp; +{ + register char *dp; + + if ((dp = (char *) calloc(1, strlen(cp) + 1)) == NULL) { + perror("msgfmt"); + exit(8); + } + return(strcpy(dp, cp)); +} + + +istail(str, of) + register char *str, *of; +{ + + return(strcmp(of, str)); +} diff -rNu xview-3.2p1.4-old/util/msgfmt/msgfmt_xv.man xview-3.2p1.4/util/msgfmt/msgfmt_xv.man --- xview-3.2p1.4-old/util/msgfmt/msgfmt_xv.man 1970-01-01 01:00:00.000000000 +0100 +++ xview-3.2p1.4/util/msgfmt/msgfmt_xv.man 2013-08-28 17:13:08.948682186 +0200 @@ -0,0 +1,161 @@ +.\" @(#)msgfmt_xv.1 1.6 90/10/12 SMI; from Sun +.TH msgfmt_xv 1 "25 July 1990" +.SH NAME +msgfmt_xv \- create a message object from a message file +.SH SYNOPSIS +.B msgfmt_xv +[ +.B \-v +] +.I filename\c +.B \&.po +\&.\|.\|. +.IX "msgfmt_xv" "" "\fLmsgfmt\fP \(em create message object file" +.IX "messages" "create message object file" +.SH DESCRIPTION +.LP +.B msgfmt_xv +creates a +message object +.I filename +.B \&.mo +file from the portable message file +.I filename\c +.BR \&.po . +.LP +The +.B .po +file contains strings extracted from source code. +.B .po +files can be edited, and the +messages in them can changed to accomodate +any language supported by the system. +.LP +The +.B xgettext_xv +command (see +.BR xgettext_xv (1)) +can be used to create the +.B default.po +file. +.LP +The +.B msgfmt_xv +command does not modify the +portable object files. +.SS "Portable Object Files" +.IX "messages" "creating portable object files" +.IX "messages" "editing messages" +.IX "\&.po files" "portable object files" +.IX "\&.mo files" "message object files" +.LP +Each +.B .po +file contains one or more lines. +Each line +contains either a comment or a statement. +Comments start the line with a hash mark (#) and end with +the newline character and are ignored. +.LP +Each directive starts on a new line and is +separated from +.BI < value > +by white space (such as one or more space or tab characters). +.BI < value > +consists of one or more quoted strings separated by white space or <CR>. +The following are valid directives: +.IX "messages" "setting the domain" +.IX "messages" "setting the message identifier" +.IX "messages" "setting the message string" +.RS +.B domain +.I domainname +.br +.B msgid +.I message_identifier +.br +.B msgstr +.I message_string +.RE +.LP +The +.B domain +directive identifies all following directives until +another +.B domain +directive is encountered as applying to the domain +.I domainname. +The +.I domainname +is a string up to +.SM MAXDOMAIN +bytes long, and can contain any characters +allowed in legal filenames. +Until the first +.B domain +directive is encountered in the file, all target strings +belong to the default domain. +The default domain is called +.BR default . +.LP +The +.B msgid +directive specifies the message identifier for the following +.B msgstr directive. +The +.I message_identifier +string identifies a target string at retrieval time. +Every statement containing a +.B msgid +directive must be followed by a statement containing a +.B msgstr +directive. +.LP +The +.B msgstr +directive specifies the target string associated with the +.I message_identifier +string declared in the immediately preceding +.B msgid +directive. +.SH OPTIONS +.TP 10 +.B \-v +Verbose. List duplicate message identifiers. +Message strings are not redefined. +.SH EXAMPLES +.LP +The following command creates a named +.B " .mo" +file for each domain named in the portable message objects +.BR " filename1.po " and " filename2.po" . +.LP +.RS +.nf +.B msgfmt_xv filename1.po filename2.po +.RE +.fi +.LP +Running +.BR msgfmt_xv (1) +on the following sample +.B .po +file creates two +.B .mo +files, named +.B first.mo +and +.B second.mo. +.RS +.nf +domain "first.mo" +msgid "aao" +msgstr "first sample message" +domain "second.mo" +msgid "bbo" +msgstr "second sample message" +.RE +.fi +.SH "SEE ALSO" +.BR xgettext (1) , +.BR gettext (3) . diff -rNu xview-3.2p1.4-old/util/xgettext/Imakefile xview-3.2p1.4/util/xgettext/Imakefile --- xview-3.2p1.4-old/util/xgettext/Imakefile 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/util/xgettext/Imakefile 2013-08-28 17:13:08.948682186 +0200 @@ -4,4 +4,4 @@ #include <XView.tmpl> MANSUFFIX =1 -SimpleProgramTarget(xgettext) +SimpleProgramTarget(xgettext_xv) diff -rNu xview-3.2p1.4-old/util/xgettext/xgettext.c xview-3.2p1.4/util/xgettext/xgettext.c --- xview-3.2p1.4-old/util/xgettext/xgettext.c 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/util/xgettext/xgettext.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1509 +0,0 @@ -#ifndef lint -#ifdef sccs -static char sccsid[] = "@(#)xgettext.c 1.10 91/09/14"; -#endif -#endif - -#include "xgettext.h" - -/* - * gettext - extract strings from gettext() calls in a C language - * source file and create a psffm: - * "Portable Source File Format for Messages" - * file template. - */ - -int write_args(), get_arguments(), sort_message(), - write_sorted_psffm(); -char *calloc(), *malloc(), *realloc(); -char *strcat(), *strcpy(), *strdup(); - -void process(), print_usage(), init_lists(), add_comment_to_domain(), - read_psffm(); -char *consume_whitespace(), *consume_symbol(), *consume_comment(), - *consume_quoted_string(), *consume_delim(); -char *get_nextline(), *write_comment(), *sort_comment(); - -FILE *defaultfp = NULL; -FILE *currentfp = NULL; -FILE *exclude_stream = NULL; - -struct list_head *get_list(); -struct list_head lists, *last_list; - -char *comment_cookie; -char *message_string = ""; -char *default_domain = "messages"; -char *file_path = "."; -char *currentf = "psffm"; -char *exclude_file; - -int readstd = 0; -int textdomain_call = 0; -int dgettext_call = 0; -int gettext_call = 0; -int verbose = 0; -int exclude = 0; -int number_lines = 0; -int use_pp = 0; -int use_msg_ids = 0; -int extract_comments = 0; -int linenum = 0; -int sorted_output = 1; -int all_strings = 0; -int update = 0; -/* -int overwrite = 0; -*/ - - -char cfilename [MAXPATHLEN+1]; - -char linebuf[LINEBUF_SIZ]; -char default_filepath[MAXPATHLEN+1]; - -main(argc, argv, envp) - int argc; - char **argv, **envp; -{ - - (void) get_arguments(&argc, &argv, envp); - - - if (readstd) { - strcpy(cfilename, "stdin"); - linenum = 0; - process(); - readstd = 0; - } - - while (argc > 0) { - if (verbose) - fprintf(stderr, "scanning file # %d = %s\n", argc, *argv); - - if (freopen(*argv, "r", stdin) == NULL) { - perror(*argv); - exit(2); - } - - strcpy(cfilename, *argv); - linenum = 0; - process(*argv); - - argc--; argv++; - } - - if (sorted_output || all_strings) { - write_sorted_psffm(); - } - - exit(0); -} - -void -print_usage() -{ - fprintf(stderr, - "\nusage: xgettext [-adnuv] [-c<flag>] [-m<tag>] [-o<default>]\n"); - fprintf(stderr, - " ... [-p<path>] [-x<xlist>] - | file\n"); - fprintf(stderr, - " xgettext -h (HELP)\n"); -} - -print_help() -{ - fprintf(stderr, "\n"); - fprintf(stderr, - "-a\t\tfind ALL strings\n"); - fprintf(stderr, - "-c<flag>\tget comments beginning with <flag>\n"); - fprintf(stderr, - "-d\t\tgenerate duplicates\n"); - fprintf(stderr, - "-h\t\tHELP !!!\n"); - fprintf(stderr, - "-m<tag>\t\tfill in msgstr with msgid<tag>\n"); - fprintf(stderr, - "-n\t\tline# comments in output\n"); - fprintf(stderr, - "-o<default>\tuse <default> for default file name\n"); - fprintf(stderr, - "-p<path>\tuse <path> for file path\n"); - fprintf(stderr, - "-u\t\tgenerate list of updated messages in <domain>.new\n"); - fprintf(stderr, - "-v\t\tverbose mode on, lists xgettext's actions\n"); -/* - fprintf(stderr, - "-w\t\toverwrite existing \".po\" files\n"); -*/ - fprintf(stderr, - "-x<xlist>\texclude strings in file <xlist> from output\n"); - fprintf(stderr, - "-\t\tread stdin, use as a filter (input only)\n"); -} - -void -init_lists() { - lists.domain = strdup(default_domain); - last_list = &lists; - read_psffm(default_domain); -} - -char * -build_path(domain, pathbuf) - char *domain, pathbuf[]; -{ - strcpy(pathbuf, file_path); - strcat(pathbuf, "/"); - strcat(pathbuf, domain); - strcat(pathbuf, ".po"); - return (pathbuf); -} - -int -get_arguments(argc, argv, envp) - int *argc; - char ***argv, **envp; -{ -/* - * Process input arguments of the form: - * - * -a emit ALL strings - * -c output comments beginning with <tag> <filename> - * -d dups mode - * -h HELP !!! - * -m output message string using message id - * -n insert line and file # comments in output - * -o specify default file name - * -p file path - * -P use preprocessor directives - * -u create update list, new messages only - * -v verbose mode on, outputs info on symbols encountered, etc. - * -w overwrite existing .po files - * -x exclude strings in exclude list <file> - * - read stdin, aka use as an input only filter - * -*/ - (*argc)--, (*argv)++; - while (*argc > 0 && *argv[0][0] == '-') { - register char *cp = &(*(*argv)++)[1]; - (*argc)--; - - switch (*cp) { - - case 0: - readstd++; - break; - - case 'a': - all_strings = 1; - if (verbose) - printf("placing all strings in .po file\n"); - break; - - case 'c': - extract_comments = 1; - if (*argc < 1) { - fprintf(stderr, - "NULL comment flag, try -c<flag>, exiting ...\n"); - exit (1); - } - - if (*(++cp) != NULL) { - comment_cookie = strdup(cp); - } else { - comment_cookie = strdup(**argv); - (*argv)++; (*argc)--; - } - if (verbose) - printf("Placing comments in \".po\" files ...\n"); - break; - - case 'd': - sorted_output = 0; - if (verbose) - printf("Writing ALL msgid's to \".po\" files\n"); - break; - - case 'm': - use_msg_ids = 1; - if (*argc < 1) { - fprintf(stderr, - "NULL message tag, try -m<tag>, exiting ...\n"); - exit (1); - } - if (*(++cp) != NULL) { - message_string = strdup(cp); - } else { - message_string = strdup(**argv); - (*argv)++; (*argc)--; - } - if (verbose) - printf("Using \"<msgid> %s\" for msgstr\n", message_string); - break; - - - case 'n': - number_lines = 1; - if (verbose) - printf("Numbering lines in \"psffm\" files ...\n"); - break; - - case 'o': - if (*argc < 1) { - fprintf(stderr, - "NULL output file, try -o<file>, exiting ...\n"); - exit (1); - } - - if (*(++cp) != NULL) { - default_domain = strdup(cp); - } else { - default_domain = strdup(**argv); - (*argv)++; (*argc)--; - } - break; - - case'P': - use_pp = 1; - break; - - case 'p': - if (*argc < 1) { - fprintf(stderr, - "NULL path, try -p<path>, exiting ...\n"); - exit (1); - } - - if (*(++cp) != NULL) { - file_path = strdup(cp); - } else { - file_path = strdup(**argv); - (*argv)++; (*argc)--; - } - - break; - - case 'u': - update = 1; - break; - - case 'v': - verbose = 1; - fprintf(stderr, "VERBOSE ON\n"); - break; - -/* - case 'w': - overwrite = 1; - break; -*/ - - case 'x': - exclude = 1; - if (*argc < 1) { - fprintf(stderr, - "NULL exclude file, try -x<xfile>, exiting ...\n"); - exit (1); - } - if (*(++cp) != NULL) { - exclude_file = strdup(cp); - } else { - exclude_file = strdup(**argv); - (*argv)++; (*argc)--; - } - - if ((exclude_stream = fopen(exclude_file, "r")) == NULL) { - fprintf(stderr, "Exclude list file: %s not found,", - exclude_file); - fprintf(stderr, " -x option reset, continuing ...\n"); - exclude = 0; - } - - if (verbose) - printf("Using \"<msgid>%s\" for msgstr\n", message_string); - - break; - - default: - fprintf(stderr, "Unrecognized option: %c\n", *cp); - print_usage(); - break; - - case 'h': - print_usage(); - print_help(); - exit(0); - } - - } - - if (*argc == 0 && !readstd ) { - fprintf(stderr, - "No input files specified, exiting ...\n"); - print_usage(); - exit (1); - } - - if (sorted_output) { - init_lists(); - } - - build_path(default_domain, default_filepath); - return (1); -} - -void -process() -{ - char *cp; - unsigned char c; - int ret; - int delim = 1; - - /* - * Outer loop scans for the beginning of label, beginning of an - * argument list, and the beginning of comments, and calls the - * appropriate function to process them. It ignores all lines - * where linebuf [0] == '#'. - * - * Labels are detected by looking for an appropriate delimiter, - * then calling is_symbol() to verify the label. If valid, the type of - * call is noted in a global variable, then the loop scans - * for the beginning of the argument list, calling write_args() - * if a quoted argument is found. - * - * Comments are detected by looking for comment delimiters. If a - * comment is found, write_comment() is called. - */ - - while (1) { - - if (!(cp = get_nextline())) { - return; - } - - while (c = *cp++) - switch (c) { - case 't': - if (!delim) { - break; - } - delim = 0; - if (is_symbol(&cp, "extdomain")) { - if (!(cp = consume_whitespace(cp))) { - goto out; - } - if (textdomain_call = (*cp == '(')) { - if (!(cp = consume_whitespace(++cp))) { - goto out; - } - if (verbose) - printf("textdomain call, arg = %s\n", cp); - } - } - - break; - - case 'd': - if (!delim) { - break; - } - delim = 0; - if (is_symbol(&cp, "gettext")) { - if(!(cp = consume_whitespace(cp))) { - goto out; - } - if (dgettext_call = (*cp == '(')) { - if (!(cp = consume_whitespace(++cp))) { - goto out; - } - if (verbose) - printf("dgettext call, arg = %s\n", cp); - } - } - break; - - case 'g': - if (!delim) { - break; - } - delim = 0; - if (is_symbol(&cp, "ettext")) { - if (!(cp = consume_whitespace(cp))) { - goto out; - } - if (gettext_call = (*cp == '(')) { - if (!(cp = consume_whitespace(++cp))) { - goto out; - } - if (verbose) - printf("gettext call, arg = %s\n", cp); - } - } - break; - - case '"': - delim = 0; - - if (cp[-2] == '\\') { - break; - } - if(cp[-2] == '\'') { - break; - } - - if (!(gettext_call || dgettext_call || textdomain_call - || all_strings)) { - if (!(cp = consume_quoted_string(cp))) { - goto out; - } - break; - } - - if ((ret = (int) write_args(&cp)) == -1) { - goto out; - } - - textdomain_call = 0; - dgettext_call = 0; - gettext_call = 0; - break; - - case '/': - delim = 1; - if (*cp != '*') { - break; - } - if (extract_comments) { - cp++; - if (sorted_output) { - cp = sort_comment(cp); - } else { - cp = write_comment(cp); - } - } else { - cp = consume_comment(cp); - } - if (!cp) - goto out; - break; - - - default: - textdomain_call = 0; - dgettext_call = 0; - gettext_call = 0; - delim = !(SYMBOL_CHAR(c)); - break; - - } /* switch (c) */ - - } /* for (cp = ... */ - -out: - - if (ferror(stdout)) { - printf("Oops\n"); - perror(cfilename); - exit(0); - } -} - -char * -consume_comment(buf) - char *buf; -{ - register char *bufptr = buf; - register char c; - - while (c = *bufptr++) { - switch (c) { - case '*': - if (*bufptr != '/') { - break; - } - return (bufptr++); - - case '\n': - if (!(bufptr = get_nextline())) { - fprintf(stderr, - "==>ERROR, end of comment never reached\n"); - return (0); - } - break; - - default: - break; - } - } -} - - -char * -consume_symbol(buf) - char *buf; -{ - register char *bufptr = buf; - register char c; - - while (c = *bufptr) { - if (SYMBOL_CHAR(c)) { - bufptr++; - continue; - } - break; - } - return (bufptr); -} - -char * -consume_quoted_string(buf) - char *buf; -{ - register char *bufptr = buf; - register char c; - - while (c = *bufptr++) { - switch (c) { - - case '\n': - fprintf(stderr, - "\"%s\", line %d: newline in string or char constant\n", - cfilename, linenum); - if (!(bufptr = get_nextline())) { - fprintf(stderr, - "\"%s\", line %d: end of string never reached\n", - cfilename, linenum); - return (0); - } - - case '"': - if (!(bufptr = consume_whitespace(bufptr))) - return (0); - if (bufptr[0] != '"') - return (bufptr); - bufptr++; - - case '\\': - if (*bufptr == '\n') { - if (!(bufptr = get_nextline())) { - fprintf(stderr, - "\"%s\", line %d: end of string never reached\n", - cfilename, linenum); - return (0); - } - } else { - bufptr++; - } - break; - - default: - break; - } - } -/* - * SHOULDN"T REACH HERE -*/ - fprintf(stderr, "ERROR ==> end of quoted string never reached\n"); - return (--bufptr); -} - -char * -consume_blankspace(buf) - char *buf; -{ - register char *bufptr = buf; - register char c; - - while (c = *bufptr) { - switch (c) { - case '\t' : - case ' ': - bufptr++; - break; - - case '\\': - if (bufptr[1] != '\n') - return (bufptr); - - default: - return (bufptr); - } - } - return (0); -} - -char * -consume_whitespace(buf) - char *buf; -{ - register char *bufptr = buf; - register char c; - - while (c = *bufptr) { - switch (c) { - case '\t' : - case ' ': - bufptr++; - break; - - case '\\': - if (bufptr[1] != '\n') - return (bufptr); - case '\n': - if (!(bufptr = get_nextline())) - return (0); - break; - - default: - return (bufptr); - } - } - return (0); -} - -char * -consume_delim(buf) - char *buf; -{ - register char *bufptr = buf; - register char c; - - while (c = *bufptr) { - if (c == '\n') { - if (!(bufptr = get_nextline())) - return (0); - } else if (SYMBOL_CHAR(c)) { - return (bufptr); - } else { - bufptr++; - } - } - return (0); -} - -int -is_symbol(lptr, label_id) - char **lptr, *label_id; -{ - int len = 0; - if (strncmp(label_id, *lptr, len = strlen(label_id))) { - *lptr = consume_symbol(*lptr); - return (0); - } - - *lptr += len; - - switch (**lptr) { - case ' ': - case '\t': - case '\(': - case '\n': - return (1); - - default: - *lptr = consume_symbol(*lptr); - return (0); - } -} - - -/* - * FIX ME !!!!!!!! -*/ -int -exclude_string(test_string) - char *test_string; -{ - char file_string[BUFSIZ]; - fseek(exclude_stream, 0, 0); /* start from begining */ - for (;;) { - if (fgets(file_string, sizeof file_string, exclude_stream) == NULL) { - break; /* reached EOF */ - } - file_string[strlen(file_string)-1] = '\0'; - if (!strcmp(test_string, file_string)) { - return (1); - } - } - - return (0); -} - -char * -get_nextline() -{ - - char *bptr; - do { - if (fgets(linebuf, sizeof (linebuf), stdin) == NULL) { - if (ferror(stdin)) { - perror("xgettext"); - exit(2); - } - return (0); - } - linenum ++; - if (use_pp) { - break; - } - if (readstd && linebuf[0] == '#') { - sscanf(linebuf, "#%d%s", &linenum, cfilename); - linenum--; - if (verbose) { - printf("file: %s seen at stdin, linenum: %d\n", - cfilename, linenum); - } - } - } while (linebuf[0] == '#'); - - return (linebuf); -} - -char * -extract_comment(cpp) - char **cpp; -{ - - register char c, *dp, *cp = *cpp; - static char *commentbuf = NULL; - static bufsiz = 0; - int offset; - - if (!commentbuf) { - commentbuf = malloc(COMMENTBUF_SIZ); - bufsiz = COMMENTBUF_SIZ; - } - - memset(commentbuf, 0, bufsiz); - commentbuf[0] = '#'; - dp = commentbuf + 1; - offset = 1; - - while (c = *cp++) { - if (offset >= (bufsiz-3)) { - commentbuf = realloc(commentbuf, bufsiz += COMMENTBUF_SIZ); - dp = commentbuf + offset; - } - - switch(c) { - - case '\n': - *dp++ = c; - offset++; - *dp++ = '#'; - offset++; - if (!(cp = get_nextline())) { - fprintf(stderr, - "==> ERROR, end of comment never reached\n"); - return (0); - } - break; - - case '*': - if (*cp == '/') { - *dp = '\n'; - return (commentbuf); - } - break; - - default: - *dp++ = c; - offset++; - break; - } - } - /* - * ERROR, SHOULDN'T EVER GET HERE ... - */ - - fprintf(stderr, "ERROR, end of comment never reached\n"); - return (cp); -} - -char * -sort_comment(cp) - char *cp; -{ - - char isitme[BUFSIZ]; - char domain[MAXNAMLEN+1]; /* MAXNAMLEN from sys/dir.h */ - char *comment; - - (void) sscanf(cp, "%s%s", isitme, domain); - if (strcmp(isitme, comment_cookie)) { - return (consume_comment(cp)); - } - if (!(comment = extract_comment(&cp))) { - return (0); - } - add_comment_to_domain(domain, comment); - return (cp); -} - -void -add_comment_to_domain(domain, commentbuf) - char *domain, *commentbuf; -{ - struct list_head *head; - if (!strcmp(domain, "-")) { - head = get_list(default_domain); - } else { - head = get_list(domain); - } - - if (!head->comments) { - head->comments = head->last_comment = - (struct comment_str *) calloc(1, sizeof(struct comment_str)); - if (!head->comments) { - perror("malloc error"); - exit(3); - } - } else { - head->last_comment = head->last_comment->next = - (struct comment_str *) calloc(1, sizeof(struct comment_str)); - if (!head->last_comment) { - perror("malloc error"); - exit(3); - } - } - head->last_comment->str = strdup(commentbuf); -} - -char * -write_comment (cp) - char *cp; -{ - - char isitme[BUFSIZ]; - char domain[MAXNAMLEN+1]; /* MAXNAMLEN from sys/dir.h */ - char comment_path[MAXPATHLEN+1]; /* MAXPATHLEN from sys/param.h */ - FILE *commentfp; - char *comment; - - - (void) sscanf(cp, "%s%s", isitme, domain); - if (strcmp(isitme, comment_cookie)) { - return (consume_comment(cp)); - } - - if (!defaultfp) { - if ((defaultfp = fopen(default_filepath, "a+")) == NULL) { - perror("xgettext"); - fprintf(stderr, - "FATAL ERROR, can't open output file: %s\n", default_filepath); - exit(2); - } - } - - if (strcmp(domain, "-")) { - memset(comment_path, 0, sizeof(comment_path)); - build_path(domain, comment_path); - if ((commentfp = fopen(comment_path, "a+")) == NULL) { - perror("xgettext"); - fprintf(stderr, - "FATAL ERROR, can't open comment file: %s\n", commentfp); - exit(2); - } - } else { - strcpy(domain, default_domain); - commentfp = defaultfp; - } - - comment = extract_comment(&cp); - fprintf(commentfp, "%s\n", comment); - close (commentfp); - return (cp); -} - -int -write_args(cpp) - char **cpp; -{ - register char *cp = *cpp; - register int c; - register char *dp; - - char msgkey[MAX_MSGID_LEN+1]; - char domain[MAX_MSGSTR_LEN+1]; - - int secondarg = 0; - - memset(msgkey, 0, sizeof(msgkey)); - memset(domain, 0, sizeof(domain)); - - if (gettext_call || all_strings) { - dp = msgkey; - } else { - dp = domain; - } - - while (c = *cp++) { - - switch (c) { - - case '"': - if (!(cp = consume_whitespace(cp))) { - return (0); - } - if (cp[0] == '"') { - cp++; - continue; - } - - if (dgettext_call && !secondarg) { - if (cp[0] == ',') { - if(!(cp = consume_whitespace(++cp))) - return (0); - if (cp[0] == '"') { - secondarg++; - dp = msgkey; - cp++; - continue; - } else { - *cpp = cp; - return (1); - } - } else { - fprintf(stderr, "Syntax error\n"); - *cpp = cp; - return (1); - } - } - cp++; - goto out; - - case '\\': - if (*cp == '\n') { - if (!(cp = get_nextline())) { - fprintf(stderr, - "==>ERROR, end of string never reached\n"); - return (0); - } - break; - } - *dp++ = c; - c = *cp++; - - default: - *dp++ = c; - break; - } -nextarg: - continue; - } - -out: - - *cpp = --cp; - - if (exclude && exclude_string(msgkey)) { - return (1); - } - - if (sorted_output) { - if (textdomain_call) { - char linebuf[MAXPATHLEN+100]; - sprintf(linebuf, - "#\n# file: %s, line number: %d, textdomain(\"%s\")\n", - cfilename, linenum, domain); - add_comment_to_domain(domain, linebuf); - return (1); - } else { - return (sort_message(domain, msgkey, "", 1)); - } - } - - if (all_strings) { - return (write_psffm(msgkey, NULL)); - } else if (gettext_call) { - return (write_psffm(msgkey, NULL)); - } else if (dgettext_call) { - return (write_psffm(msgkey, domain)); - } else if (textdomain_call) { - return (write_psffm(NULL, domain)); - } -} - -int -write_psffm(msgkey, domain) -char *msgkey, *domain; -{ - static char saved_domain[MAXNAMLEN+1]; - static char domain_path[MAXPATHLEN+1]; - struct stat psffm_stat; - - FILE *psffmfp; - - if (!defaultfp) { - if ((defaultfp = fopen(default_filepath, "a+")) == NULL) { - perror("xgettext"); - fprintf(stderr, - "FATAL ERROR, can't open output file: %s\n", - default_filepath); - exit(2); - } - } - - - if (domain && dgettext_call) { - if (strcmp(saved_domain, domain)) { - - if (verbose) { - printf("entering new domain, "); - printf("old domain: %s new domain: %s\n", - saved_domain, domain); - } - - memset(saved_domain, 0, sizeof(saved_domain)); - strcpy(saved_domain, domain); - - memset(domain_path, 0, sizeof(domain_path)); - build_path(domain, domain_path); - - if (currentfp) { - fclose(currentfp); - } - - if ((currentfp = fopen(domain_path, "a+")) == NULL) { - perror("xgettext"); - fprintf(stderr, "FATAL ERROR, can't open output file: %s\n", - domain_path); - exit(2); - } - - if (stat(domain_path, &psffm_stat) == -1) { - perror("xgettext"); - fprintf(stderr, "FATAL ERROR, can't stat output file: %s\n", - domain_path); - exit(2); - } - - if (psffm_stat.st_size < sizeof("domain")) { - if (verbose) - printf("adding domain token: %s to file: %s\n", - domain, domain_path); - fprintf(currentfp, "domain "); - fprintf(currentfp, "\"%s\"\n", domain); - - /* - * Shouldn't happen ... - */ - if (msgkey == NULL) { - return (ferror(currentfp)); - } - } - - } - psffmfp = currentfp; - } else { - psffmfp = defaultfp; - } - - fseek(psffmfp, 0, 2); - - if (textdomain_call) { - fprintf(psffmfp, "#\n# %s: textdomain(), line number: %d, domain: %s\n", - cfilename, linenum, domain); - } - - if (msgkey) { - if (verbose) { - printf("writing message key: %s to file: %s\n", - msgkey, domain_path); - if (use_msg_ids) - printf("using message id as messsage string\n"); - } - - if (number_lines) { - fprintf(psffmfp, "#\n# %s: line number: %d\n", - cfilename, linenum); - } - fprintf(psffmfp, "msgid "); - fprintf(psffmfp, "\"%s\"\n", msgkey); - fprintf(psffmfp, "msgstr "); - if (use_msg_ids) { - fprintf(psffmfp, "\"%s%s\"\n", msgkey, message_string); - } else { - fprintf(psffmfp, "\n"); - } - } - fflush(psffmfp); - return (ferror(psffmfp)); -} - -struct list_head * -get_list(domain) - char *domain; -{ - -/* - * Find sorted list for a given domain - * make new list if domain not found -*/ - - if (domain[0] != NULL) { - register struct list_head *head = &lists; - register int found; - - while (head) { - if (!strcmp(head->domain, domain)) { - return (head); - } - head = head->next_list; - } - - last_list = last_list->next_list = - (struct list_head *) calloc(1, sizeof(struct list_head)); - if (!last_list) { - perror("malloc error"); - exit(3); - } - last_list->domain = strdup(domain); - read_psffm(domain); - return (last_list); - } else { - return (&lists); - } -} - -int -sort_message(domain, msgid, msgstr, new) - char *domain, *msgid, *msgstr; - short new; -{ - register struct list_element *lp, *lplt, *lpgt; - int i, lessthan; - struct list_head *head; - -/* - * Find correct list to add output to -*/ - - head = get_list(domain); - lp = head->first_element; - lplt = lpgt = 0; - while (lp) { - i = strcmp(msgid, lp->msgid); - if (i < 0) { - lpgt = lp; - break; - } else if (i == 0) { /* found! */ - goto add_comments; - } - lplt = lp; - lp = lp->next; - } - - if (!(lp = (struct list_element *)calloc(1, sizeof(struct list_element)))){ - perror("xgettext malloc error"); - exit(3); - } - lp->msgid = strdup(msgid); - lp->msgstr = strdup(msgstr); - lp->new = new; - - if (lplt == 0) { - head->first_element = lp; - lp->next = lpgt; - } else if (lpgt == 0) { - lplt->next = lp; - } else { - lp->next = lpgt; - lplt->next = lp; - } - -add_comments: - - if (head->comments) { - if (!lp->comments) { - lp->comments = head->comments; - } else { - lp->last_comment->next = head->comments; - } - lp->last_comment = head->last_comment; - head->comments = head->last_comment = 0; - } - - if (number_lines) { - char linebuf[MAXPATHLEN+100]; - sprintf(linebuf, "#\n# file: %s, line number: %d\n", - cfilename, linenum); - if (!lp->comments) { - lp->comments = lp->last_comment = - (struct comment_str *) calloc(1, sizeof(struct comment_str)); - if (!lp->comments) { - perror("malloc error"); - exit(3); - } - } else { - lp->last_comment = lp->last_comment->next = - (struct comment_str *) calloc(1, sizeof(struct comment_str)); - if (!lp->last_comment) { - perror("malloc error"); - exit(3); - } - } - lp->last_comment->str = strdup(linebuf); - } - - return (0); -} - -int -write_sorted_psffm() -{ - FILE *fp; - register struct list_head *list; - struct list_element *lp; - register struct comment_str *cp; - char output_filename[MAXPATHLEN]; - - list = &lists; - while (list) { - strcpy(output_filename, file_path); - strcat(output_filename, "/"); - strcat(output_filename, list->domain); - if (update) { - strcat(output_filename, ".update"); - } else { - strcat(output_filename, ".po"); - } - fp = fopen(output_filename, "w"); - fprintf(fp, "domain "); - fprintf(fp, "\"%s\"\n", list->domain); - - if (fp == NULL) { - perror(default_filepath); - exit(2); - } - - lp = list->first_element; - while (lp) { - if (update && !lp->new) { - lp = lp->next; - continue; - } - cp = lp->comments; - while (cp) { - fprintf(fp, "%s", cp->str); - cp = cp->next; - } - fprintf(fp, "msgid \"%s\"\n", lp->msgid); - if (use_msg_ids) { - fprintf(fp, "msgstr \"%s%s\"\n", - lp->msgid, message_string); - } else { - if (lp->msgstr[0] == '\0') { - fprintf(fp, "msgstr\n"); - } else { - fprintf(fp, "msgstr \"%s\"\n", - lp->msgstr); - } - } - lp = lp->next; - } - - cp = list->comments; - while (cp) { - fprintf(fp, "%s", cp->str); - cp = cp->next; - } - - (void) fclose(fp); - list = list->next_list; - } -} - -void -read_psffm(domain) - char *domain; -{ - FILE *msgfileptr = NULL; - - char inbuf[MAX_VALUE_LEN+32]; - char *inbufptr; - char msgfile[MAXPATHLEN]; - char current_domain[MAX_DOMAIN_LENGTH]; - char msgid[MAX_VALUE_LEN+1]; - char msgstr[MAX_VALUE_LEN+1]; - register char *bufptr; - - int inlinenum = 0; - int domain_set = 0; - int whitespace = 0; - int quotefound = 0; - int ignored = 0; - int indomain = 0; - int inmsgid = 0; - int inmsgstr = 0; - char c; - int number_lines_state = number_lines; - number_lines = 0; - - build_path(domain, msgfile); - if (!(msgfileptr = fopen(msgfile, "r"))) { - number_lines = number_lines_state; - return; - } - - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - - while (1) { - memset(inbuf, 0, sizeof(inbuf)); - if (fgets(inbuf, sizeof(inbuf), msgfileptr) == NULL) { - break; - } - inlinenum ++; - - if (verbose) { - printf("Scanning: %s, line number %d:\n%s\n", - msgfile, inlinenum, inbuf); - } - - inbufptr = inbuf; - whitespace = 0; - - switch (*inbufptr) { - case '#': /* comment */ - if (inmsgstr) { - sort_message(domain, msgid, msgstr, 0); - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - inmsgid = 0; - inmsgstr = 0; - indomain = 0; - } - add_comment_to_domain(domain, inbufptr); - case '\n': - ignored = 1; - break; - - case '\"': - case ' ': - case '\t': - whitespace = 1; - default: - ignored = 0; - break; - } - - if (ignored) { - continue; - } - - /* - * Process MSGID Tokens, must not have just seen one unless - * this line begins with whitespace -or- " - */ - - if ((!strncmp(MSGID_TOKEN, inbuf, sizeof(MSGID_TOKEN)-1)) - || (whitespace && inmsgid)) { - if (inmsgid && !whitespace) { - fprintf(stderr, "Consecutive MSGID tokens, file: %s", msgfile); - fprintf(stderr, "line number: %d\n", inlinenum); - } - if (inmsgstr) { - sort_message(domain, msgid, msgstr, 0); - - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - } - - - if (inmsgid) { - inbufptr = consume_blankspace(inbuf); - } else { - inbufptr = consume_blankspace(inbuf + - sizeof(MSGID_TOKEN)-1); - bufptr = msgid; - } - - if (!inbufptr) - return; - inmsgid = 1; - inmsgstr = 0; - indomain = 0; - goto load_buffer; - } - - /* - * Process MSGSTR Tokens, must not have just seen one unless - * this line begins with whitespace -or- " - */ - - if ((!strncmp(MSGSTR_TOKEN, inbuf, sizeof(MSGSTR_TOKEN)-1)) - || (whitespace && inmsgstr)) { - if (inmsgstr && !whitespace) { - fprintf(stderr, "Consecutive MSGSTR tokens, file: %s", msgfile); - fprintf(stderr, "line number: %d\n", inlinenum); - } - - if (inmsgstr) { - inbufptr = consume_blankspace(inbuf); - } else { - inbufptr = consume_blankspace(inbuf + - sizeof(MSGSTR_TOKEN)-1); - bufptr = msgstr; - } - - if (!inbufptr) - return; - inmsgstr = 1; - inmsgid = 0; - indomain = 0; - goto load_buffer; - } - - /* - * Process DOMAIN Tokens, add message id and message string to - * sorted list if msgstr was being processed, - */ - - if (!strncmp(DOMAIN_TOKEN, inbuf, sizeof(DOMAIN_TOKEN)-1)) { - if (inmsgstr) { - sort_message(domain, msgid, msgstr, 0); - memset(msgid, 0, sizeof(msgid)); - memset(msgstr, 0, sizeof(msgstr)); - } - - domain_set = 1; - indomain = 1; - inmsgid = 0; - inmsgstr = 0; - - inbufptr = consume_blankspace(inbuf+ sizeof(DOMAIN_TOKEN)); - memset(current_domain, 0, sizeof(current_domain)); - bufptr = domain = current_domain; - if (!inbufptr) - return; - } - -load_buffer: - - quotefound = 0; - - while (c=*inbufptr++) { - switch (c) { - - case '\n': - case '"': - break; - - default: - *bufptr++ = c; - } - } - - } - - if (inmsgstr) { - sort_message(domain, msgid, msgstr, 0); - } - number_lines = number_lines_state; - return; -} diff -rNu xview-3.2p1.4-old/util/xgettext/xgettext.man xview-3.2p1.4/util/xgettext/xgettext.man --- xview-3.2p1.4-old/util/xgettext/xgettext.man 2013-08-28 17:12:56.308682001 +0200 +++ xview-3.2p1.4/util/xgettext/xgettext.man 1970-01-01 01:00:00.000000000 +0100 @@ -1,164 +0,0 @@ -.\" @(#)xgettext.1 1.4 90/08/20 SMI; from Sun -.TH xgettext 1 "14 Sep 1990" -.SH NAME -xgettext \- conditionally extract strings from C programs -.SH SYNOPSIS -.br -.B xgettext -.B \-d -[ -.B cmnopvhP -] -[ -.BI \-o \&directory-prefix -] -[ -.BI \-x \&exclude-list -] -[ -.I filename \|.\|.\|. -] -.br -.B xgettext -[ -.B \-amopvhP -] -[ -.BI \-x \&exclude-list -] -[ -.I filename \|.\|.\|. -] -.br -.\"... gwen please check indexes. -.IX xgettext "" "\fLxgettext\fP \(em conditionally extract strings" -.IX messages "conditionally extract strings" "" "conditionally extract strings" -.SH DESCRIPTION -.LP -.B xgettext -is used to automate the creation of portable message files. -A portable message file contains copies of "C" strings that are found in -"C" source code in -.I filename. -When the -.B -d -option is specified, -.B xgettext -places the extracted strings in the file -.I name\c -.BR \&.po . -.I name -is either the domain specified in a -.B dgettext -call, or -.B messages.po -for strings extracted from -.B gettext -and -.B textdomain -calls. If the -.B -d -flag is not specified, -.B xgettext -places all the strings in -.BR messages.po . -The portable message file can be used as input to the -.BR msgfmt (1) -utility, which will produce a binary form of the message file than can be -used at application run-time. -.SH OPTIONS -.TP 10 -.BI \-a -Extract ALL strings, not just those found in -.BR gettext , -.BR dgettext , -and -.B textdomain -calls. -.TP 10 -.BI \-c flag -Comments beginning with -.I flag filename -on the first line of the comment are added to file -.IR filename -as -.I # -delimited comments. -.TP 10 -.B \-d -Produce duplicates. Does not sort output when -writing the portable message -file and will not overwrite existing output files. -Places output -from each domain specified in a -.B dgettext -call into a separate file named for the domain, -.IR ie . -.IB name .po -.TP 10 -.BI \-c flag -Comments beginning with -.I flag filename -on the first line of the comment are added to file -.IR filename -as -.I # -delimited comments. -.TP 10 -.BI \-m string -Causes -.B xgettext -to fill in the -.B msgstr -line of the portable message files it produces. -.B xgettext -uses the -corresponding msgid string -extracted from the "C" file, appending -.IR string . -Useful for debugging purposes. -.TP 10 -.B \-n -Add -.I # -delimited line number comments to output file indicating -the line number in the source file -where each extracted string is encountered. -.TP 10 -.BI \-o filename -rename the default output file from -.BR messages.po -to -.IR filename . -.TP 10 -.BI \-p pathname -Specify the directory where the output files will be placed. -This option overrides the current working -directory. -.TP 10 -.BI \-x filename -Specify a file that contains a list of strings that -are not be extracted from the input files. -Each string to be excluded must appear on a line by itself -in the file -.I filename. -.TP 10 -.B \-P -include strings in pre-processor statements. -.TP 10 -.B \-v -Verbose mode. -.TP 10 -.B \-h -Print a help message on standard output. -.SH FILES -.TP 14 -.TP -.B messages.po -is always created, but may be empty. -.SH "SEE ALSO" -.BR msgfmt (1) , -.BR xstr (1) , -.BR gettext , -.BR dgettext , -.BR textdomain (3) . diff -rNu xview-3.2p1.4-old/util/xgettext/xgettext_xv.c xview-3.2p1.4/util/xgettext/xgettext_xv.c --- xview-3.2p1.4-old/util/xgettext/xgettext_xv.c 1970-01-01 01:00:00.000000000 +0100 +++ xview-3.2p1.4/util/xgettext/xgettext_xv.c 2013-08-28 17:13:08.956682186 +0200 @@ -0,0 +1,1509 @@ +#ifndef lint +#ifdef sccs +static char sccsid[] = "@(#)xgettext.c 1.10 91/09/14"; +#endif +#endif + +#include "xgettext.h" + +/* + * gettext - extract strings from gettext() calls in a C language + * source file and create a psffm: + * "Portable Source File Format for Messages" + * file template. + */ + +int write_args(), get_arguments(), sort_message(), + write_sorted_psffm(); +char *calloc(), *malloc(), *realloc(); +char *strcat(), *strcpy(), *strdup(); + +void process(), print_usage(), init_lists(), add_comment_to_domain(), + read_psffm(); +char *consume_whitespace(), *consume_symbol(), *consume_comment(), + *consume_quoted_string(), *consume_delim(); +char *get_nextline(), *write_comment(), *sort_comment(); + +FILE *defaultfp = NULL; +FILE *currentfp = NULL; +FILE *exclude_stream = NULL; + +struct list_head *get_list(); +struct list_head lists, *last_list; + +char *comment_cookie; +char *message_string = ""; +char *default_domain = "messages"; +char *file_path = "."; +char *currentf = "psffm"; +char *exclude_file; + +int readstd = 0; +int textdomain_call = 0; +int dgettext_call = 0; +int gettext_call = 0; +int verbose = 0; +int exclude = 0; +int number_lines = 0; +int use_pp = 0; +int use_msg_ids = 0; +int extract_comments = 0; +int linenum = 0; +int sorted_output = 1; +int all_strings = 0; +int update = 0; +/* +int overwrite = 0; +*/ + + +char cfilename [MAXPATHLEN+1]; + +char linebuf[LINEBUF_SIZ]; +char default_filepath[MAXPATHLEN+1]; + +main(argc, argv, envp) + int argc; + char **argv, **envp; +{ + + (void) get_arguments(&argc, &argv, envp); + + + if (readstd) { + strcpy(cfilename, "stdin"); + linenum = 0; + process(); + readstd = 0; + } + + while (argc > 0) { + if (verbose) + fprintf(stderr, "scanning file # %d = %s\n", argc, *argv); + + if (freopen(*argv, "r", stdin) == NULL) { + perror(*argv); + exit(2); + } + + strcpy(cfilename, *argv); + linenum = 0; + process(*argv); + + argc--; argv++; + } + + if (sorted_output || all_strings) { + write_sorted_psffm(); + } + + exit(0); +} + +void +print_usage() +{ + fprintf(stderr, + "\nusage: xgettext [-adnuv] [-c<flag>] [-m<tag>] [-o<default>]\n"); + fprintf(stderr, + " ... [-p<path>] [-x<xlist>] - | file\n"); + fprintf(stderr, + " xgettext -h (HELP)\n"); +} + +print_help() +{ + fprintf(stderr, "\n"); + fprintf(stderr, + "-a\t\tfind ALL strings\n"); + fprintf(stderr, + "-c<flag>\tget comments beginning with <flag>\n"); + fprintf(stderr, + "-d\t\tgenerate duplicates\n"); + fprintf(stderr, + "-h\t\tHELP !!!\n"); + fprintf(stderr, + "-m<tag>\t\tfill in msgstr with msgid<tag>\n"); + fprintf(stderr, + "-n\t\tline# comments in output\n"); + fprintf(stderr, + "-o<default>\tuse <default> for default file name\n"); + fprintf(stderr, + "-p<path>\tuse <path> for file path\n"); + fprintf(stderr, + "-u\t\tgenerate list of updated messages in <domain>.new\n"); + fprintf(stderr, + "-v\t\tverbose mode on, lists xgettext's actions\n"); +/* + fprintf(stderr, + "-w\t\toverwrite existing \".po\" files\n"); +*/ + fprintf(stderr, + "-x<xlist>\texclude strings in file <xlist> from output\n"); + fprintf(stderr, + "-\t\tread stdin, use as a filter (input only)\n"); +} + +void +init_lists() { + lists.domain = strdup(default_domain); + last_list = &lists; + read_psffm(default_domain); +} + +char * +build_path(domain, pathbuf) + char *domain, pathbuf[]; +{ + strcpy(pathbuf, file_path); + strcat(pathbuf, "/"); + strcat(pathbuf, domain); + strcat(pathbuf, ".po"); + return (pathbuf); +} + +int +get_arguments(argc, argv, envp) + int *argc; + char ***argv, **envp; +{ +/* + * Process input arguments of the form: + * + * -a emit ALL strings + * -c output comments beginning with <tag> <filename> + * -d dups mode + * -h HELP !!! + * -m output message string using message id + * -n insert line and file # comments in output + * -o specify default file name + * -p file path + * -P use preprocessor directives + * -u create update list, new messages only + * -v verbose mode on, outputs info on symbols encountered, etc. + * -w overwrite existing .po files + * -x exclude strings in exclude list <file> + * - read stdin, aka use as an input only filter + * +*/ + (*argc)--, (*argv)++; + while (*argc > 0 && *argv[0][0] == '-') { + register char *cp = &(*(*argv)++)[1]; + (*argc)--; + + switch (*cp) { + + case 0: + readstd++; + break; + + case 'a': + all_strings = 1; + if (verbose) + printf("placing all strings in .po file\n"); + break; + + case 'c': + extract_comments = 1; + if (*argc < 1) { + fprintf(stderr, + "NULL comment flag, try -c<flag>, exiting ...\n"); + exit (1); + } + + if (*(++cp) != NULL) { + comment_cookie = strdup(cp); + } else { + comment_cookie = strdup(**argv); + (*argv)++; (*argc)--; + } + if (verbose) + printf("Placing comments in \".po\" files ...\n"); + break; + + case 'd': + sorted_output = 0; + if (verbose) + printf("Writing ALL msgid's to \".po\" files\n"); + break; + + case 'm': + use_msg_ids = 1; + if (*argc < 1) { + fprintf(stderr, + "NULL message tag, try -m<tag>, exiting ...\n"); + exit (1); + } + if (*(++cp) != NULL) { + message_string = strdup(cp); + } else { + message_string = strdup(**argv); + (*argv)++; (*argc)--; + } + if (verbose) + printf("Using \"<msgid> %s\" for msgstr\n", message_string); + break; + + + case 'n': + number_lines = 1; + if (verbose) + printf("Numbering lines in \"psffm\" files ...\n"); + break; + + case 'o': + if (*argc < 1) { + fprintf(stderr, + "NULL output file, try -o<file>, exiting ...\n"); + exit (1); + } + + if (*(++cp) != NULL) { + default_domain = strdup(cp); + } else { + default_domain = strdup(**argv); + (*argv)++; (*argc)--; + } + break; + + case'P': + use_pp = 1; + break; + + case 'p': + if (*argc < 1) { + fprintf(stderr, + "NULL path, try -p<path>, exiting ...\n"); + exit (1); + } + + if (*(++cp) != NULL) { + file_path = strdup(cp); + } else { + file_path = strdup(**argv); + (*argv)++; (*argc)--; + } + + break; + + case 'u': + update = 1; + break; + + case 'v': + verbose = 1; + fprintf(stderr, "VERBOSE ON\n"); + break; + +/* + case 'w': + overwrite = 1; + break; +*/ + + case 'x': + exclude = 1; + if (*argc < 1) { + fprintf(stderr, + "NULL exclude file, try -x<xfile>, exiting ...\n"); + exit (1); + } + if (*(++cp) != NULL) { + exclude_file = strdup(cp); + } else { + exclude_file = strdup(**argv); + (*argv)++; (*argc)--; + } + + if ((exclude_stream = fopen(exclude_file, "r")) == NULL) { + fprintf(stderr, "Exclude list file: %s not found,", + exclude_file); + fprintf(stderr, " -x option reset, continuing ...\n"); + exclude = 0; + } + + if (verbose) + printf("Using \"<msgid>%s\" for msgstr\n", message_string); + + break; + + default: + fprintf(stderr, "Unrecognized option: %c\n", *cp); + print_usage(); + break; + + case 'h': + print_usage(); + print_help(); + exit(0); + } + + } + + if (*argc == 0 && !readstd ) { + fprintf(stderr, + "No input files specified, exiting ...\n"); + print_usage(); + exit (1); + } + + if (sorted_output) { + init_lists(); + } + + build_path(default_domain, default_filepath); + return (1); +} + +void +process() +{ + char *cp; + unsigned char c; + int ret; + int delim = 1; + + /* + * Outer loop scans for the beginning of label, beginning of an + * argument list, and the beginning of comments, and calls the + * appropriate function to process them. It ignores all lines + * where linebuf [0] == '#'. + * + * Labels are detected by looking for an appropriate delimiter, + * then calling is_symbol() to verify the label. If valid, the type of + * call is noted in a global variable, then the loop scans + * for the beginning of the argument list, calling write_args() + * if a quoted argument is found. + * + * Comments are detected by looking for comment delimiters. If a + * comment is found, write_comment() is called. + */ + + while (1) { + + if (!(cp = get_nextline())) { + return; + } + + while (c = *cp++) + switch (c) { + case 't': + if (!delim) { + break; + } + delim = 0; + if (is_symbol(&cp, "extdomain")) { + if (!(cp = consume_whitespace(cp))) { + goto out; + } + if (textdomain_call = (*cp == '(')) { + if (!(cp = consume_whitespace(++cp))) { + goto out; + } + if (verbose) + printf("textdomain call, arg = %s\n", cp); + } + } + + break; + + case 'd': + if (!delim) { + break; + } + delim = 0; + if (is_symbol(&cp, "gettext")) { + if(!(cp = consume_whitespace(cp))) { + goto out; + } + if (dgettext_call = (*cp == '(')) { + if (!(cp = consume_whitespace(++cp))) { + goto out; + } + if (verbose) + printf("dgettext call, arg = %s\n", cp); + } + } + break; + + case 'g': + if (!delim) { + break; + } + delim = 0; + if (is_symbol(&cp, "ettext")) { + if (!(cp = consume_whitespace(cp))) { + goto out; + } + if (gettext_call = (*cp == '(')) { + if (!(cp = consume_whitespace(++cp))) { + goto out; + } + if (verbose) + printf("gettext call, arg = %s\n", cp); + } + } + break; + + case '"': + delim = 0; + + if (cp[-2] == '\\') { + break; + } + if(cp[-2] == '\'') { + break; + } + + if (!(gettext_call || dgettext_call || textdomain_call + || all_strings)) { + if (!(cp = consume_quoted_string(cp))) { + goto out; + } + break; + } + + if ((ret = (int) write_args(&cp)) == -1) { + goto out; + } + + textdomain_call = 0; + dgettext_call = 0; + gettext_call = 0; + break; + + case '/': + delim = 1; + if (*cp != '*') { + break; + } + if (extract_comments) { + cp++; + if (sorted_output) { + cp = sort_comment(cp); + } else { + cp = write_comment(cp); + } + } else { + cp = consume_comment(cp); + } + if (!cp) + goto out; + break; + + + default: + textdomain_call = 0; + dgettext_call = 0; + gettext_call = 0; + delim = !(SYMBOL_CHAR(c)); + break; + + } /* switch (c) */ + + } /* for (cp = ... */ + +out: + + if (ferror(stdout)) { + printf("Oops\n"); + perror(cfilename); + exit(0); + } +} + +char * +consume_comment(buf) + char *buf; +{ + register char *bufptr = buf; + register char c; + + while (c = *bufptr++) { + switch (c) { + case '*': + if (*bufptr != '/') { + break; + } + return (bufptr++); + + case '\n': + if (!(bufptr = get_nextline())) { + fprintf(stderr, + "==>ERROR, end of comment never reached\n"); + return (0); + } + break; + + default: + break; + } + } +} + + +char * +consume_symbol(buf) + char *buf; +{ + register char *bufptr = buf; + register char c; + + while (c = *bufptr) { + if (SYMBOL_CHAR(c)) { + bufptr++; + continue; + } + break; + } + return (bufptr); +} + +char * +consume_quoted_string(buf) + char *buf; +{ + register char *bufptr = buf; + register char c; + + while (c = *bufptr++) { + switch (c) { + + case '\n': + fprintf(stderr, + "\"%s\", line %d: newline in string or char constant\n", + cfilename, linenum); + if (!(bufptr = get_nextline())) { + fprintf(stderr, + "\"%s\", line %d: end of string never reached\n", + cfilename, linenum); + return (0); + } + + case '"': + if (!(bufptr = consume_whitespace(bufptr))) + return (0); + if (bufptr[0] != '"') + return (bufptr); + bufptr++; + + case '\\': + if (*bufptr == '\n') { + if (!(bufptr = get_nextline())) { + fprintf(stderr, + "\"%s\", line %d: end of string never reached\n", + cfilename, linenum); + return (0); + } + } else { + bufptr++; + } + break; + + default: + break; + } + } +/* + * SHOULDN"T REACH HERE +*/ + fprintf(stderr, "ERROR ==> end of quoted string never reached\n"); + return (--bufptr); +} + +char * +consume_blankspace(buf) + char *buf; +{ + register char *bufptr = buf; + register char c; + + while (c = *bufptr) { + switch (c) { + case '\t' : + case ' ': + bufptr++; + break; + + case '\\': + if (bufptr[1] != '\n') + return (bufptr); + + default: + return (bufptr); + } + } + return (0); +} + +char * +consume_whitespace(buf) + char *buf; +{ + register char *bufptr = buf; + register char c; + + while (c = *bufptr) { + switch (c) { + case '\t' : + case ' ': + bufptr++; + break; + + case '\\': + if (bufptr[1] != '\n') + return (bufptr); + case '\n': + if (!(bufptr = get_nextline())) + return (0); + break; + + default: + return (bufptr); + } + } + return (0); +} + +char * +consume_delim(buf) + char *buf; +{ + register char *bufptr = buf; + register char c; + + while (c = *bufptr) { + if (c == '\n') { + if (!(bufptr = get_nextline())) + return (0); + } else if (SYMBOL_CHAR(c)) { + return (bufptr); + } else { + bufptr++; + } + } + return (0); +} + +int +is_symbol(lptr, label_id) + char **lptr, *label_id; +{ + int len = 0; + if (strncmp(label_id, *lptr, len = strlen(label_id))) { + *lptr = consume_symbol(*lptr); + return (0); + } + + *lptr += len; + + switch (**lptr) { + case ' ': + case '\t': + case '\(': + case '\n': + return (1); + + default: + *lptr = consume_symbol(*lptr); + return (0); + } +} + + +/* + * FIX ME !!!!!!!! +*/ +int +exclude_string(test_string) + char *test_string; +{ + char file_string[BUFSIZ]; + fseek(exclude_stream, 0, 0); /* start from begining */ + for (;;) { + if (fgets(file_string, sizeof file_string, exclude_stream) == NULL) { + break; /* reached EOF */ + } + file_string[strlen(file_string)-1] = '\0'; + if (!strcmp(test_string, file_string)) { + return (1); + } + } + + return (0); +} + +char * +get_nextline() +{ + + char *bptr; + do { + if (fgets(linebuf, sizeof (linebuf), stdin) == NULL) { + if (ferror(stdin)) { + perror("xgettext"); + exit(2); + } + return (0); + } + linenum ++; + if (use_pp) { + break; + } + if (readstd && linebuf[0] == '#') { + sscanf(linebuf, "#%d%s", &linenum, cfilename); + linenum--; + if (verbose) { + printf("file: %s seen at stdin, linenum: %d\n", + cfilename, linenum); + } + } + } while (linebuf[0] == '#'); + + return (linebuf); +} + +char * +extract_comment(cpp) + char **cpp; +{ + + register char c, *dp, *cp = *cpp; + static char *commentbuf = NULL; + static bufsiz = 0; + int offset; + + if (!commentbuf) { + commentbuf = malloc(COMMENTBUF_SIZ); + bufsiz = COMMENTBUF_SIZ; + } + + memset(commentbuf, 0, bufsiz); + commentbuf[0] = '#'; + dp = commentbuf + 1; + offset = 1; + + while (c = *cp++) { + if (offset >= (bufsiz-3)) { + commentbuf = realloc(commentbuf, bufsiz += COMMENTBUF_SIZ); + dp = commentbuf + offset; + } + + switch(c) { + + case '\n': + *dp++ = c; + offset++; + *dp++ = '#'; + offset++; + if (!(cp = get_nextline())) { + fprintf(stderr, + "==> ERROR, end of comment never reached\n"); + return (0); + } + break; + + case '*': + if (*cp == '/') { + *dp = '\n'; + return (commentbuf); + } + break; + + default: + *dp++ = c; + offset++; + break; + } + } + /* + * ERROR, SHOULDN'T EVER GET HERE ... + */ + + fprintf(stderr, "ERROR, end of comment never reached\n"); + return (cp); +} + +char * +sort_comment(cp) + char *cp; +{ + + char isitme[BUFSIZ]; + char domain[MAXNAMLEN+1]; /* MAXNAMLEN from sys/dir.h */ + char *comment; + + (void) sscanf(cp, "%s%s", isitme, domain); + if (strcmp(isitme, comment_cookie)) { + return (consume_comment(cp)); + } + if (!(comment = extract_comment(&cp))) { + return (0); + } + add_comment_to_domain(domain, comment); + return (cp); +} + +void +add_comment_to_domain(domain, commentbuf) + char *domain, *commentbuf; +{ + struct list_head *head; + if (!strcmp(domain, "-")) { + head = get_list(default_domain); + } else { + head = get_list(domain); + } + + if (!head->comments) { + head->comments = head->last_comment = + (struct comment_str *) calloc(1, sizeof(struct comment_str)); + if (!head->comments) { + perror("malloc error"); + exit(3); + } + } else { + head->last_comment = head->last_comment->next = + (struct comment_str *) calloc(1, sizeof(struct comment_str)); + if (!head->last_comment) { + perror("malloc error"); + exit(3); + } + } + head->last_comment->str = strdup(commentbuf); +} + +char * +write_comment (cp) + char *cp; +{ + + char isitme[BUFSIZ]; + char domain[MAXNAMLEN+1]; /* MAXNAMLEN from sys/dir.h */ + char comment_path[MAXPATHLEN+1]; /* MAXPATHLEN from sys/param.h */ + FILE *commentfp; + char *comment; + + + (void) sscanf(cp, "%s%s", isitme, domain); + if (strcmp(isitme, comment_cookie)) { + return (consume_comment(cp)); + } + + if (!defaultfp) { + if ((defaultfp = fopen(default_filepath, "a+")) == NULL) { + perror("xgettext"); + fprintf(stderr, + "FATAL ERROR, can't open output file: %s\n", default_filepath); + exit(2); + } + } + + if (strcmp(domain, "-")) { + memset(comment_path, 0, sizeof(comment_path)); + build_path(domain, comment_path); + if ((commentfp = fopen(comment_path, "a+")) == NULL) { + perror("xgettext"); + fprintf(stderr, + "FATAL ERROR, can't open comment file: %s\n", commentfp); + exit(2); + } + } else { + strcpy(domain, default_domain); + commentfp = defaultfp; + } + + comment = extract_comment(&cp); + fprintf(commentfp, "%s\n", comment); + close (commentfp); + return (cp); +} + +int +write_args(cpp) + char **cpp; +{ + register char *cp = *cpp; + register int c; + register char *dp; + + char msgkey[MAX_MSGID_LEN+1]; + char domain[MAX_MSGSTR_LEN+1]; + + int secondarg = 0; + + memset(msgkey, 0, sizeof(msgkey)); + memset(domain, 0, sizeof(domain)); + + if (gettext_call || all_strings) { + dp = msgkey; + } else { + dp = domain; + } + + while (c = *cp++) { + + switch (c) { + + case '"': + if (!(cp = consume_whitespace(cp))) { + return (0); + } + if (cp[0] == '"') { + cp++; + continue; + } + + if (dgettext_call && !secondarg) { + if (cp[0] == ',') { + if(!(cp = consume_whitespace(++cp))) + return (0); + if (cp[0] == '"') { + secondarg++; + dp = msgkey; + cp++; + continue; + } else { + *cpp = cp; + return (1); + } + } else { + fprintf(stderr, "Syntax error\n"); + *cpp = cp; + return (1); + } + } + cp++; + goto out; + + case '\\': + if (*cp == '\n') { + if (!(cp = get_nextline())) { + fprintf(stderr, + "==>ERROR, end of string never reached\n"); + return (0); + } + break; + } + *dp++ = c; + c = *cp++; + + default: + *dp++ = c; + break; + } +nextarg: + continue; + } + +out: + + *cpp = --cp; + + if (exclude && exclude_string(msgkey)) { + return (1); + } + + if (sorted_output) { + if (textdomain_call) { + char linebuf[MAXPATHLEN+100]; + sprintf(linebuf, + "#\n# file: %s, line number: %d, textdomain(\"%s\")\n", + cfilename, linenum, domain); + add_comment_to_domain(domain, linebuf); + return (1); + } else { + return (sort_message(domain, msgkey, "", 1)); + } + } + + if (all_strings) { + return (write_psffm(msgkey, NULL)); + } else if (gettext_call) { + return (write_psffm(msgkey, NULL)); + } else if (dgettext_call) { + return (write_psffm(msgkey, domain)); + } else if (textdomain_call) { + return (write_psffm(NULL, domain)); + } +} + +int +write_psffm(msgkey, domain) +char *msgkey, *domain; +{ + static char saved_domain[MAXNAMLEN+1]; + static char domain_path[MAXPATHLEN+1]; + struct stat psffm_stat; + + FILE *psffmfp; + + if (!defaultfp) { + if ((defaultfp = fopen(default_filepath, "a+")) == NULL) { + perror("xgettext"); + fprintf(stderr, + "FATAL ERROR, can't open output file: %s\n", + default_filepath); + exit(2); + } + } + + + if (domain && dgettext_call) { + if (strcmp(saved_domain, domain)) { + + if (verbose) { + printf("entering new domain, "); + printf("old domain: %s new domain: %s\n", + saved_domain, domain); + } + + memset(saved_domain, 0, sizeof(saved_domain)); + strcpy(saved_domain, domain); + + memset(domain_path, 0, sizeof(domain_path)); + build_path(domain, domain_path); + + if (currentfp) { + fclose(currentfp); + } + + if ((currentfp = fopen(domain_path, "a+")) == NULL) { + perror("xgettext"); + fprintf(stderr, "FATAL ERROR, can't open output file: %s\n", + domain_path); + exit(2); + } + + if (stat(domain_path, &psffm_stat) == -1) { + perror("xgettext"); + fprintf(stderr, "FATAL ERROR, can't stat output file: %s\n", + domain_path); + exit(2); + } + + if (psffm_stat.st_size < sizeof("domain")) { + if (verbose) + printf("adding domain token: %s to file: %s\n", + domain, domain_path); + fprintf(currentfp, "domain "); + fprintf(currentfp, "\"%s\"\n", domain); + + /* + * Shouldn't happen ... + */ + if (msgkey == NULL) { + return (ferror(currentfp)); + } + } + + } + psffmfp = currentfp; + } else { + psffmfp = defaultfp; + } + + fseek(psffmfp, 0, 2); + + if (textdomain_call) { + fprintf(psffmfp, "#\n# %s: textdomain(), line number: %d, domain: %s\n", + cfilename, linenum, domain); + } + + if (msgkey) { + if (verbose) { + printf("writing message key: %s to file: %s\n", + msgkey, domain_path); + if (use_msg_ids) + printf("using message id as messsage string\n"); + } + + if (number_lines) { + fprintf(psffmfp, "#\n# %s: line number: %d\n", + cfilename, linenum); + } + fprintf(psffmfp, "msgid "); + fprintf(psffmfp, "\"%s\"\n", msgkey); + fprintf(psffmfp, "msgstr "); + if (use_msg_ids) { + fprintf(psffmfp, "\"%s%s\"\n", msgkey, message_string); + } else { + fprintf(psffmfp, "\n"); + } + } + fflush(psffmfp); + return (ferror(psffmfp)); +} + +struct list_head * +get_list(domain) + char *domain; +{ + +/* + * Find sorted list for a given domain + * make new list if domain not found +*/ + + if (domain[0] != NULL) { + register struct list_head *head = &lists; + register int found; + + while (head) { + if (!strcmp(head->domain, domain)) { + return (head); + } + head = head->next_list; + } + + last_list = last_list->next_list = + (struct list_head *) calloc(1, sizeof(struct list_head)); + if (!last_list) { + perror("malloc error"); + exit(3); + } + last_list->domain = strdup(domain); + read_psffm(domain); + return (last_list); + } else { + return (&lists); + } +} + +int +sort_message(domain, msgid, msgstr, new) + char *domain, *msgid, *msgstr; + short new; +{ + register struct list_element *lp, *lplt, *lpgt; + int i, lessthan; + struct list_head *head; + +/* + * Find correct list to add output to +*/ + + head = get_list(domain); + lp = head->first_element; + lplt = lpgt = 0; + while (lp) { + i = strcmp(msgid, lp->msgid); + if (i < 0) { + lpgt = lp; + break; + } else if (i == 0) { /* found! */ + goto add_comments; + } + lplt = lp; + lp = lp->next; + } + + if (!(lp = (struct list_element *)calloc(1, sizeof(struct list_element)))){ + perror("xgettext malloc error"); + exit(3); + } + lp->msgid = strdup(msgid); + lp->msgstr = strdup(msgstr); + lp->new = new; + + if (lplt == 0) { + head->first_element = lp; + lp->next = lpgt; + } else if (lpgt == 0) { + lplt->next = lp; + } else { + lp->next = lpgt; + lplt->next = lp; + } + +add_comments: + + if (head->comments) { + if (!lp->comments) { + lp->comments = head->comments; + } else { + lp->last_comment->next = head->comments; + } + lp->last_comment = head->last_comment; + head->comments = head->last_comment = 0; + } + + if (number_lines) { + char linebuf[MAXPATHLEN+100]; + sprintf(linebuf, "#\n# file: %s, line number: %d\n", + cfilename, linenum); + if (!lp->comments) { + lp->comments = lp->last_comment = + (struct comment_str *) calloc(1, sizeof(struct comment_str)); + if (!lp->comments) { + perror("malloc error"); + exit(3); + } + } else { + lp->last_comment = lp->last_comment->next = + (struct comment_str *) calloc(1, sizeof(struct comment_str)); + if (!lp->last_comment) { + perror("malloc error"); + exit(3); + } + } + lp->last_comment->str = strdup(linebuf); + } + + return (0); +} + +int +write_sorted_psffm() +{ + FILE *fp; + register struct list_head *list; + struct list_element *lp; + register struct comment_str *cp; + char output_filename[MAXPATHLEN]; + + list = &lists; + while (list) { + strcpy(output_filename, file_path); + strcat(output_filename, "/"); + strcat(output_filename, list->domain); + if (update) { + strcat(output_filename, ".update"); + } else { + strcat(output_filename, ".po"); + } + fp = fopen(output_filename, "w"); + fprintf(fp, "domain "); + fprintf(fp, "\"%s\"\n", list->domain); + + if (fp == NULL) { + perror(default_filepath); + exit(2); + } + + lp = list->first_element; + while (lp) { + if (update && !lp->new) { + lp = lp->next; + continue; + } + cp = lp->comments; + while (cp) { + fprintf(fp, "%s", cp->str); + cp = cp->next; + } + fprintf(fp, "msgid \"%s\"\n", lp->msgid); + if (use_msg_ids) { + fprintf(fp, "msgstr \"%s%s\"\n", + lp->msgid, message_string); + } else { + if (lp->msgstr[0] == '\0') { + fprintf(fp, "msgstr\n"); + } else { + fprintf(fp, "msgstr \"%s\"\n", + lp->msgstr); + } + } + lp = lp->next; + } + + cp = list->comments; + while (cp) { + fprintf(fp, "%s", cp->str); + cp = cp->next; + } + + (void) fclose(fp); + list = list->next_list; + } +} + +void +read_psffm(domain) + char *domain; +{ + FILE *msgfileptr = NULL; + + char inbuf[MAX_VALUE_LEN+32]; + char *inbufptr; + char msgfile[MAXPATHLEN]; + char current_domain[MAX_DOMAIN_LENGTH]; + char msgid[MAX_VALUE_LEN+1]; + char msgstr[MAX_VALUE_LEN+1]; + register char *bufptr; + + int inlinenum = 0; + int domain_set = 0; + int whitespace = 0; + int quotefound = 0; + int ignored = 0; + int indomain = 0; + int inmsgid = 0; + int inmsgstr = 0; + char c; + int number_lines_state = number_lines; + number_lines = 0; + + build_path(domain, msgfile); + if (!(msgfileptr = fopen(msgfile, "r"))) { + number_lines = number_lines_state; + return; + } + + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + + while (1) { + memset(inbuf, 0, sizeof(inbuf)); + if (fgets(inbuf, sizeof(inbuf), msgfileptr) == NULL) { + break; + } + inlinenum ++; + + if (verbose) { + printf("Scanning: %s, line number %d:\n%s\n", + msgfile, inlinenum, inbuf); + } + + inbufptr = inbuf; + whitespace = 0; + + switch (*inbufptr) { + case '#': /* comment */ + if (inmsgstr) { + sort_message(domain, msgid, msgstr, 0); + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + inmsgid = 0; + inmsgstr = 0; + indomain = 0; + } + add_comment_to_domain(domain, inbufptr); + case '\n': + ignored = 1; + break; + + case '\"': + case ' ': + case '\t': + whitespace = 1; + default: + ignored = 0; + break; + } + + if (ignored) { + continue; + } + + /* + * Process MSGID Tokens, must not have just seen one unless + * this line begins with whitespace -or- " + */ + + if ((!strncmp(MSGID_TOKEN, inbuf, sizeof(MSGID_TOKEN)-1)) + || (whitespace && inmsgid)) { + if (inmsgid && !whitespace) { + fprintf(stderr, "Consecutive MSGID tokens, file: %s", msgfile); + fprintf(stderr, "line number: %d\n", inlinenum); + } + if (inmsgstr) { + sort_message(domain, msgid, msgstr, 0); + + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + } + + + if (inmsgid) { + inbufptr = consume_blankspace(inbuf); + } else { + inbufptr = consume_blankspace(inbuf + + sizeof(MSGID_TOKEN)-1); + bufptr = msgid; + } + + if (!inbufptr) + return; + inmsgid = 1; + inmsgstr = 0; + indomain = 0; + goto load_buffer; + } + + /* + * Process MSGSTR Tokens, must not have just seen one unless + * this line begins with whitespace -or- " + */ + + if ((!strncmp(MSGSTR_TOKEN, inbuf, sizeof(MSGSTR_TOKEN)-1)) + || (whitespace && inmsgstr)) { + if (inmsgstr && !whitespace) { + fprintf(stderr, "Consecutive MSGSTR tokens, file: %s", msgfile); + fprintf(stderr, "line number: %d\n", inlinenum); + } + + if (inmsgstr) { + inbufptr = consume_blankspace(inbuf); + } else { + inbufptr = consume_blankspace(inbuf + + sizeof(MSGSTR_TOKEN)-1); + bufptr = msgstr; + } + + if (!inbufptr) + return; + inmsgstr = 1; + inmsgid = 0; + indomain = 0; + goto load_buffer; + } + + /* + * Process DOMAIN Tokens, add message id and message string to + * sorted list if msgstr was being processed, + */ + + if (!strncmp(DOMAIN_TOKEN, inbuf, sizeof(DOMAIN_TOKEN)-1)) { + if (inmsgstr) { + sort_message(domain, msgid, msgstr, 0); + memset(msgid, 0, sizeof(msgid)); + memset(msgstr, 0, sizeof(msgstr)); + } + + domain_set = 1; + indomain = 1; + inmsgid = 0; + inmsgstr = 0; + + inbufptr = consume_blankspace(inbuf+ sizeof(DOMAIN_TOKEN)); + memset(current_domain, 0, sizeof(current_domain)); + bufptr = domain = current_domain; + if (!inbufptr) + return; + } + +load_buffer: + + quotefound = 0; + + while (c=*inbufptr++) { + switch (c) { + + case '\n': + case '"': + break; + + default: + *bufptr++ = c; + } + } + + } + + if (inmsgstr) { + sort_message(domain, msgid, msgstr, 0); + } + number_lines = number_lines_state; + return; +} diff -rNu xview-3.2p1.4-old/util/xgettext/xgettext_xv.man xview-3.2p1.4/util/xgettext/xgettext_xv.man --- xview-3.2p1.4-old/util/xgettext/xgettext_xv.man 1970-01-01 01:00:00.000000000 +0100 +++ xview-3.2p1.4/util/xgettext/xgettext_xv.man 2013-08-28 17:13:08.956682186 +0200 @@ -0,0 +1,164 @@ +.\" @(#)xgettext_xv.1 1.4 90/08/20 SMI; from Sun +.TH xgettext_xv 1 "14 Sep 1990" +.SH NAME +xgettext_xv \- conditionally extract strings from C programs +.SH SYNOPSIS +.br +.B xgettext_xv +.B \-d +[ +.B cmnopvhP +] +[ +.BI \-o \&directory-prefix +] +[ +.BI \-x \&exclude-list +] +[ +.I filename \|.\|.\|. +] +.br +.B xgettext_xv +[ +.B \-amopvhP +] +[ +.BI \-x \&exclude-list +] +[ +.I filename \|.\|.\|. +] +.br +.\"... gwen please check indexes. +.IX xgettext_xv "" "\fLxgettext\fP \(em conditionally extract strings" +.IX messages "conditionally extract strings" "" "conditionally extract strings" +.SH DESCRIPTION +.LP +.B xgettext_xv +is used to automate the creation of portable message files. +A portable message file contains copies of "C" strings that are found in +"C" source code in +.I filename. +When the +.B -d +option is specified, +.B xgettext_xv +places the extracted strings in the file +.I name\c +.BR \&.po . +.I name +is either the domain specified in a +.B dgettext +call, or +.B messages.po +for strings extracted from +.B gettext +and +.B textdomain +calls. If the +.B -d +flag is not specified, +.B xgettext_xv +places all the strings in +.BR messages.po . +The portable message file can be used as input to the +.BR msgfmt_xv (1) +utility, which will produce a binary form of the message file than can be +used at application run-time. +.SH OPTIONS +.TP 10 +.BI \-a +Extract ALL strings, not just those found in +.BR gettext , +.BR dgettext , +and +.B textdomain +calls. +.TP 10 +.BI \-c flag +Comments beginning with +.I flag filename +on the first line of the comment are added to file +.IR filename +as +.I # +delimited comments. +.TP 10 +.B \-d +Produce duplicates. Does not sort output when +writing the portable message +file and will not overwrite existing output files. +Places output +from each domain specified in a +.B dgettext +call into a separate file named for the domain, +.IR ie . +.IB name .po +.TP 10 +.BI \-c flag +Comments beginning with +.I flag filename +on the first line of the comment are added to file +.IR filename +as +.I # +delimited comments. +.TP 10 +.BI \-m string +Causes +.B xgettext_xv +to fill in the +.B msgstr +line of the portable message files it produces. +.B xgettext_xv +uses the +corresponding msgid string +extracted from the "C" file, appending +.IR string . +Useful for debugging purposes. +.TP 10 +.B \-n +Add +.I # +delimited line number comments to output file indicating +the line number in the source file +where each extracted string is encountered. +.TP 10 +.BI \-o filename +rename the default output file from +.BR messages.po +to +.IR filename . +.TP 10 +.BI \-p pathname +Specify the directory where the output files will be placed. +This option overrides the current working +directory. +.TP 10 +.BI \-x filename +Specify a file that contains a list of strings that +are not be extracted from the input files. +Each string to be excluded must appear on a line by itself +in the file +.I filename. +.TP 10 +.B \-P +include strings in pre-processor statements. +.TP 10 +.B \-v +Verbose mode. +.TP 10 +.B \-h +Print a help message on standard output. +.SH FILES +.TP 14 +.TP +.B messages.po +is always created, but may be empty. +.SH "SEE ALSO" +.BR msgfmt_xv (1) , +.BR xstr (1) , +.BR gettext , +.BR dgettext , +.BR textdomain (3) .
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor