diff --git a/Changelog b/Changelog index 4b67264..0411842 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +version 0.3.2dev: + +- Added support for cygwin platform. + version 0.3.1: - SPACE in minibuffer does completion only if a completion method is diff --git a/Makefile b/Makefile index 90526b6..9f32228 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ DEP_LIBS+=libqhtml/libqhtml.a LIBS+=-L./libqhtml -lqhtml OBJS+=html.o docbook.o ifndef CONFIG_WIN32 -TARGETS+=html2png +TARGETS+=html2png$(EXE) endif endif @@ -139,7 +139,7 @@ OBJS+= video.o image.o DEP_LIBS+=$(FFMPEG_LIBDIR)/libavcodec/libavcodec.a $(FFMPEG_LIBDIR)/libavformat/libavformat.a LIBS+= -L$(FFMPEG_LIBDIR)/libavcodec -L$(FFMPEG_LIBDIR)/libavformat -lavformat -lavcodec -lz -lpthread DEFINES+= -I$(FFMPEG_SRCDIR)/libavcodec -I$(FFMPEG_SRCDIR)/libavformat -TARGETS+=ffplay +TARGETS+=ffplay$(EXE) endif # must be the last object @@ -150,18 +150,19 @@ all: lib $(TARGETS) lib: make -C libqhtml all -qe_g: $(OBJS) $(DEP_LIBS) +qe_g$(EXE): $(OBJS) $(DEP_LIBS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) -qe$(EXE): qe_g +qe$(EXE): qe_g$(EXE) + rm -f $@ cp $< $@ $(STRIP) $@ @ls -l $@ -ffplay: qe$(EXE) +ffplay$(EXE): qe$(EXE) ln -sf $< $@ -qe.o: qe.c qe.h qfribidi.h +qe.o: qe.c qe.h qfribidi.h qeconfig.h charset.o: charset.c qe.h @@ -182,23 +183,22 @@ html2png.o: html2png.c qe.h clean: make -C libqhtml clean - rm -f *.o *~ TAGS gmon.out core \ - qe qe_g qe.exe qfribidi kmaptoqe ligtoqe \ - html2png fbftoqe fbffonts.c + rm -f *.o *.exe *~ TAGS gmon.out core qe.exe.stackdump \ + qe qe_g qfribidi kmaptoqe ligtoqe html2png fbftoqe fbffonts.c distclean: clean rm -f config.h config.mak -install: qe qe.1 kmaps ligatures html2png - install -m 755 qe $(prefix)/bin/qemacs - ln -sf qemacs $(prefix)/bin/qe +install: qe$(EXE) qe.1 kmaps ligatures html2png$(EXE) + install -m 755 qe$(EXE) $(prefix)/bin/qemacs + ln -sf qemacs $(prefix)/bin/qe$(EXE) ifdef CONFIG_FFMPEG ln -sf qemacs $(prefix)/bin/ffplay endif mkdir -p $(prefix)/share/qe install kmaps ligatures $(prefix)/share/qe install qe.1 $(prefix)/man/man1 - install -m 755 -s html2png $(prefix)/bin + install -m 755 -s html2png$(EXE) $(prefix)/bin TAGS: force etags *.[ch] @@ -246,24 +246,24 @@ FILE=qemacs-$(VERSION) tar: rm -rf /tmp/$(FILE) mkdir -p /tmp/$(FILE) - cp -P $(FILES) /tmp/$(FILE) - ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) ) + cp --parents $(FILES) /tmp/$(FILE) + ( cd /tmp ; tar zcvf $(HOME)/$(FILE).tar.gz $(FILE) ) rm -rf /tmp/$(FILE) # # Test for bidir algorithm # -qfribidi: qfribidi.c +qfribidi$(EXE): qfribidi.c $(HOST_CC) $(CFLAGS) -DTEST -o $@ $< # # build ligature table # -ligtoqe: ligtoqe.c +ligtoqe$(EXE): ligtoqe.c $(HOST_CC) $(CFLAGS) -o $@ $< ifdef BUILD_ALL -ligatures: unifont.lig ligtoqe +ligatures: unifont.lig ligtoqe$(EXE) ./ligtoqe unifont.lig $@ endif @@ -282,11 +282,11 @@ KMAPS=Arabic.kmap ArmenianEast.kmap ArmenianWest.kmap Chinese-CJ.kmap \ KMAPS_DIR=$(prefix)/share/yudit/data KMAPS:=$(addprefix $(KMAPS_DIR)/, $(KMAPS)) -kmaptoqe: kmaptoqe.c +kmaptoqe$(EXE): kmaptoqe.c $(HOST_CC) $(CFLAGS) -o $@ $< ifdef BUILD_ALL -kmaps: kmaptoqe $(KMAPS) +kmaps: kmaptoqe$(EXE) $(KMAPS) ./kmaptoqe $@ $(KMAPS) endif @@ -301,11 +301,11 @@ CP=8859_2.cp cp1125.cp cp737.cp koi8_r.cp \ JIS0208.TXT JIS0212.TXT CP:=$(addprefix cp/,$(CP)) -cptoqe: cptoqe.c +cptoqe$(EXE): cptoqe.c $(HOST_CC) $(CFLAGS) -o $@ $< ifdef BUILD_ALL -charset_table.c: cptoqe $(CP) +charset_table.c: cptoqe$(EXE) $(CP) ./cptoqe $(CP) > $@ endif @@ -318,10 +318,10 @@ times8.fbf times10.fbf times12.fbf times14.fbf times18.fbf times24.fbf\ unifont.fbf FONTS:=$(addprefix fonts/,$(FONTS)) -fbftoqe: fbftoqe.c +fbftoqe$(EXE): fbftoqe.c $(CC) $(CFLAGS) -o $@ $< -fbffonts.c: fbftoqe $(FONTS) +fbffonts.c: fbftoqe$(EXE) $(FONTS) ./fbftoqe $(FONTS) > $@ # @@ -332,7 +332,7 @@ OBJS=util.o cutils.o \ display.o unicode_join.o charset.o charsetmore.o charset_table.o \ libfbf.o fbfrender.o cfb.o fbffonts.o -html2png: html2png.o $(OBJS) libqhtml/libqhtml.a +html2png$(EXE): html2png.o $(OBJS) libqhtml/libqhtml.a $(HOST_CC) $(LDFLAGS) -o $@ html2png.o $(OBJS) \ -L./libqhtml -lqhtml $(HTMLTOPPM_LIBS) diff --git a/TODO b/TODO index 126ca07..32f792b 100644 --- a/TODO +++ b/TODO @@ -66,3 +66,22 @@ Ideas - improve dired (file commands, nicer display) - rethink mode specific commands -> add inheritance for all commands ? - shorter command types handling (suppress ESxxx and use one type per arg) + +Clean window deletion mess: +--------------------------- + +detach window from tree and keep attached to buffer if last +detach window from tree and put in delayed free tree otherwise + +edit_close(s) +do_delete_window(s) + bufed_select(s) if vertical split + dired_select(s) if vertical split +do_less_quit(s) +do_delete_other_windows(s) deletes other windows (!) +do_minibuffer_exit(s) also deletes completion_popup +insert_window_left() deletes some left-most windows + do_list_buffers() + do_dired() + +- dpy_open_font should never return NULL, must have a system font. diff --git a/charset.c b/charset.c index c8bba91..8dcd508 100644 --- a/charset.c +++ b/charset.c @@ -236,7 +236,7 @@ static void decode_utf8_init(CharsetDecodeState *s) static int decode_utf8_func(CharsetDecodeState *s, const unsigned char **pp) { - return utf8_decode((const char **)pp); + return utf8_decode((const char **)(void *)pp); } unsigned char *encode_utf8(QECharset *charset, unsigned char *q, int c) diff --git a/configure b/configure index 21a4d4a..f322cc8 100755 --- a/configure +++ b/configure @@ -42,6 +42,7 @@ esac gprof="no" network="yes" win32="no" +cygwin="no" lshared="no" extralibs="-lm" simpleidct="yes" @@ -56,27 +57,32 @@ png="yes" ffmpeg="no" html="yes" plugins="yes" +initcalls="yes" +exe="" # OS specific targetos=`uname -s` case $targetos in -BeOS) -prefix="/boot/home/config" -# helps building libavcodec -CFLAGS="-O2 -DPIC" -# no need for libm, but the inet stuff -# Check for BONE -if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then -extralibs="-lbind -lsocket" -else -echo "Not sure building for net_server will succeed... good luck." -extralibs="-lsocket" -fi ;; -BSD/OS) -extralibs="-lpoll -lgnugetopt -lm" -make="gmake" -;; -*) ;; + BeOS) + prefix="/boot/home/config" + # helps building libavcodec + CFLAGS="-O2 -DPIC" + # no need for libm, but the inet stuff + # Check for BONE + if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then + extralibs="-lbind -lsocket" + else + echo "Not sure building for net_server will succeed... good luck." + extralibs="-lsocket" + fi ;; + BSD/OS) + extralibs="-lpoll -lgnugetopt -lm" + make="gmake" + ;; + CYGWIN*) + cygwin="yes" + ;; + *) ;; esac # find source path @@ -91,8 +97,8 @@ if test -z "$source_path" -o "$source_path" = "." ; then fi if test -d ./ffmpeg ; then - ffmpeg="yes" - ffmpeg_srcdir="./ffmpeg" + ffmpeg="yes" + ffmpeg_srcdir="./ffmpeg" fi for opt do @@ -121,6 +127,8 @@ for opt do ;; --enable-win32) win32="yes" ;; + --enable-cygwin) cygwin="yes" ; + ;; --enable-shared) lshared="yes" ;; --disable-mpegaudio-hp) mpegaudio_hp="no" @@ -154,6 +162,20 @@ fi if test "$win32" = "yes" ; then cross_prefix="i386-mingw32msvc-" network="no" + exe=".exe" +fi + +if test "$cygwin" = "yes" ; then + plugins="no" + x11="no" + xv="no" + xrender="no" + png="no" + ffmpeg="no" + html="no" + plugins="no" + initcalls="no" + exe=".exe" fi # endianness : guess with cpu type. Should also use prefix @@ -176,10 +198,10 @@ EOF _memalign=no _malloc_h=no if $cc -o $TMPO $TMPC 2> /dev/null ; then -_malloc_h=yes -_memalign=yes -# check for memalign - atmos -cat > $TMPC << EOF + _malloc_h=yes + _memalign=yes + # check for memalign - atmos + cat > $TMPC << EOF #include int main ( void ) { char *string = NULL; @@ -187,7 +209,7 @@ string = memalign(64, sizeof(char)); return 0; } EOF -$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no + $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no fi if test "$ffmpeg" = "yes" ; then @@ -233,6 +255,7 @@ echo "Standard options:" echo " --help print this message" echo " --prefix=PREFIX install in PREFIX [$prefix]" echo " --enable-win32 enable win32 cross compile" +echo " --enable-cygwin compile for cygwin systems" echo " --disable-x11 disable Xwindow support" echo " --disable-xv disable Xvideo extension support" echo " --disable-xrender disable Xrender extension support" @@ -264,6 +287,7 @@ echo "Xvideo support $xv" echo "libpng support $png" echo "Graphical HTML $html" echo "Plugins support $plugins" +echo "Initcall support $initcalls" echo "FFMPEG support $ffmpeg" echo "Creating config.mak and config.h" @@ -281,6 +305,8 @@ echo "AR=$ar" >> config.mak echo "STRIP=$strip -s -R .comment -R .note" >> config.mak echo "CFLAGS=$CFLAGS" >> config.mak echo "LDFLAGS=$LDFLAGS" >> config.mak +echo "EXE=$exe" >> config.mak + if test "$cpu" = "x86" ; then echo "TARGET_ARCH_X86=yes" >> config.mak echo "#define ARCH_X86 1" >> $TMPH @@ -308,8 +334,8 @@ if test "$lshared" = "yes" ; then fi echo "EXTRALIBS=$extralibs" >> config.mak echo -n "VERSION=" >>config.mak -echo -n `head $source_path/VERSION` >>config.mak -echo "" >>config.mak +echo -n `head $source_path/VERSION` >> config.mak +echo "" >> config.mak echo -n "#define QE_VERSION \"" >> $TMPH echo -n `head $source_path/VERSION` >> $TMPH echo "\"" >> $TMPH @@ -323,6 +349,11 @@ if test "$win32" = "yes" ; then echo "CONFIG_WIN32=yes" >> config.mak fi +if test "$cygwin" = "yes" ; then + echo "#define CONFIG_CYGWIN 1" >> $TMPH + echo "CONFIG_CYGWIN=yes" >> config.mak +fi + if test "$x11" = "yes" ; then echo "#define CONFIG_X11 1" >> $TMPH echo "CONFIG_X11=yes" >> config.mak @@ -353,6 +384,11 @@ if test "$plugins" = "yes" ; then echo "CONFIG_DLL=yes" >> config.mak fi +if test "$initcalls" = "yes" ; then + echo "#define CONFIG_INIT_CALLS 1" >> $TMPH + echo "CONFIG_INIT_CALLS=yes" >> config.mak +fi + if test "$png" = "yes" ; then echo "#define CONFIG_PNG_OUTPUT 1" >> $TMPH echo "CONFIG_PNG_OUTPUT=yes" >> config.mak @@ -380,9 +416,9 @@ echo "SRC_PATH=$source_path" >> config.mak diff $TMPH config.h >/dev/null 2>&1 if test $? -ne 0 ; then - mv -f $TMPH config.h + mv -f $TMPH config.h else - echo "config.h is unchanged" + echo "config.h is unchanged" fi rm -f $TMPO $TMPC $TMPE $TMPS $TMPH diff --git a/libqhtml/Makefile b/libqhtml/Makefile index 0a77869..4cc6855 100644 --- a/libqhtml/Makefile +++ b/libqhtml/Makefile @@ -25,16 +25,16 @@ $(LIB): $(OBJS) $(AR) rc $@ $(OBJS) clean: - rm -f *~ *.o *.a csstoqe html_style.c docbook_style.c + rm -f *~ *.o *.a *.exe csstoqe html_style.c docbook_style.c # # build default style sheet file # -csstoqe: csstoqe.c +csstoqe$(EXE): csstoqe.c $(HOST_CC) $(CFLAGS) -o $@ $< -html_style.c: html.css csstoqe +html_style.c: html.css csstoqe$(EXE) ./csstoqe html_style < $< > $@ -docbook_style.c: docbook.css csstoqe +docbook_style.c: docbook.css csstoqe$(EXE) ./csstoqe docbook_style < $< > $@ diff --git a/qe.c b/qe.c index 434af38..3fef518 100644 --- a/qe.c +++ b/qe.c @@ -29,8 +29,10 @@ typedef struct HistoryEntry { char name[32]; } HistoryEntry; +#ifdef CONFIG_INIT_CALLS static int (*__initcall_first)(void) __init_call = NULL; static void (*__exitcall_first)(void) __exit_call = NULL; +#endif static int get_line_height(QEditScreen *screen, int style_index); void print_at_byte(QEditScreen *screen, @@ -173,6 +175,7 @@ static void qe_register_binding2(int key, { int nb_keys; unsigned int keys[3]; + nb_keys = 0; if (key >= KEY_CTRLX(0) && key <= KEY_CTRLX(0xff)) { keys[nb_keys++] = KEY_CTRL('x'); @@ -6165,7 +6168,7 @@ static CmdOptionDef cmd_options[] = { { NULL }, }; -#if defined(__GNUC__) || defined(__TINYC__) +#if (defined(__GNUC__) || defined(__TINYC__)) && defined(CONFIG_INIT_CALLS) static inline void init_all_modules(void) { int (*initcall)(void); @@ -6187,11 +6190,75 @@ static inline void init_all_modules(void) } } #else + /* cannot use elf sections, so we initialize the modules manually */ +/* Should use a shell script to process objects and construct + * initcall array: + cat $(OBJS) | tr -cs 'a-z0-9_' \\n | grep -E '^module_[a-z]+_init$' + */ + +extern void module_hex_init(void); /* hex.c(351) */ +extern void module_list_init(void); /* list.c(102) */ +extern void module_tty_init(void); /* tty.c(567) */ +extern void module_charset_more_init(void); /* charsetmore.c(324) */ +extern void module_unihex_init(void); /* unihex.c(184) */ +extern void module_c_init(void); /* clang.c(567) */ +extern void module_latex_init(void); /* latex-mode.c(338) */ +extern void module_xml_init(void); /* xml.c(202) */ +extern void module_bufed_init(void); /* bufed.c(197) */ +extern void module_shell_init(void); /* shell.c(922) */ +extern void module_dired_init(void); /* dired.c(369) */ +extern void module_win32_init(void); /* win32.c(504) */ +extern void module_x11_init(void); /* x11.c(1704) */ +extern void module_html_init(void); /* html.c(894) */ +extern void module_docbook_init(void); /* docbook.c(53) */ +extern void module_video_init(void); /* video.c(979) */ +extern void module_image_init(void); /* image.c(844) */ +extern void module_mpeg_init(void); /* mpeg.c(181) */ + static inline void init_all_modules(void) { - x11_init(); - c_init(); + /* modules must be initialized in link order (!) + OBJS=qe.o charset.o buffer.o \ + input.o unicode_join.o display.o util.o hex.o list.o cutils.o + OBJS+= unix.o tty.o + OBJS+= charsetmore.o charset_table.o + OBJS+= unihex.o clang.o latex-mode.o xml.o bufed.o + OBJS+= shell.o dired.o + OBJS+= win32.o + OBJS+= libfbf.o fbfrender.o cfb.o fbffonts.o + OBJS+= x11.o + OBJS+= html.o docbook.o + OBJS+= arabic.o indic.o qfribidi.o unihex.o + OBJS+= video.o image.o + OBJS+= qeend.o + */ + module_hex_init(); /* hex.c(351) */ + module_list_init(); /* list.c(102) */ + module_tty_init(); /* tty.c(567) */ + module_charset_more_init(); /* charsetmore.c(324) */ + module_unihex_init(); /* unihex.c(184) */ + module_c_init(); /* clang.c(567) */ + module_latex_init(); /* latex-mode.c(338) */ + module_xml_init(); /* xml.c(202) */ + module_bufed_init(); /* bufed.c(197) */ + module_shell_init(); /* shell.c(922) */ + module_dired_init(); /* dired.c(369) */ +#ifdef CONFIG_WIN32 + module_win32_init(); /* win32.c(504) */ +#endif +#ifdef CONFIG_X11 + module_x11_init(); /* x11.c(1704) */ +#endif +#ifdef CONFIG_HTML + module_html_init(); /* html.c(894) */ + module_docbook_init(); /* docbook.c(53) */ +#endif +#ifdef CONFIG_FFMPEG + module_video_init(); /* video.c(979) */ + module_image_init(); /* image.c(844) */ + //module_mpeg_init(); /* mpeg.c(181) */ +#endif } #endif @@ -6210,7 +6277,7 @@ void load_all_modules(void) while (!find_file_next(ffs, filename, sizeof(filename))) { h = dlopen(filename, RTLD_LAZY); if (!h) { - char *error = dlerror(); + char *error = dlerror(); fprintf(stderr, "Could not open module '%s': %s\n", filename, error); continue; diff --git a/qe.h b/qe.h index 277fc0b..840f735 100644 --- a/qe.h +++ b/qe.h @@ -572,7 +572,7 @@ extern EditBufferDataType raw_data_type; #else /* QE_MODULE */ -#if defined(__GNUC__) || defined(__TINYC__) +#if (defined(__GNUC__) || defined(__TINYC__)) && defined(CONFIG_INIT_CALLS) /* make sure that the keyword is not disabled by glibc (TINYC case) */ #undef __attribute__ @@ -592,7 +592,7 @@ extern EditBufferDataType raw_data_type; #define __exit_call #define qe_module_init(fn) \ - int module_ ## fn (void) { fn(); } + int module_ ## fn (void) { return fn(); } #define qe_module_exit(fn) diff --git a/qeend.c b/qeend.c index aa3783a..e3ccbb7 100644 --- a/qeend.c +++ b/qeend.c @@ -1,7 +1,11 @@ #include #include "qe.h" +#ifdef CONFIG_INIT_CALLS + /* add empty pointers at the end of init and cleanup sections */ static int (*__initcall_end)(void) __init_call = NULL; static void (*__exitcall_end)(void) __exit_call = NULL; + +#endif