From: Wolfgang Bumiller Date: Mon, 7 Apr 2014 12:23:35 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/master' into cooking X-Git-Tag: xonotic-v0.8.0~4 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=e8133893a0bd4e1cc469864b3d6f621ed5f3186f;hp=9e5d02dab00fde31e20efa9c3200165424375857 Merge remote-tracking branch 'origin/master' into cooking --- diff --git a/Makefile b/Makefile index 3097368..3f286e2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ include include.mk UNAME ?= $(shell uname) -CYGWIN = $(findstring CYGWIN, $(UNAME)) -MINGW = $(findstring MINGW32, $(UNAME)) +CYGWIN = $(findstring CYGWIN, $(UNAME)) +MINGW = $(findstring MINGW, $(UNAME)) CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing -Wno-attributes #turn on tons of warnings if clang is present @@ -40,7 +40,8 @@ endif # do this last otherwise there is whitespace in the command output and # it makes my OCD act up -CFLAGS += $(OPTIONAL) +CFLAGS += $(OPTIONAL_CFLAGS) +LDFLAGS += $(OPTIONAL_LDFLAGS) #we have duplicate object files when dealing with creating a simple list #for dependinces. To combat this we use some clever recrusive-make to diff --git a/distro/Makefile b/distro/Makefile index 384b1fa..3436cca 100644 --- a/distro/Makefile +++ b/distro/Makefile @@ -9,19 +9,58 @@ endif .NOTPARALLEL: base .NOTPARALLEL: upload +HEADER=\e[5;32;40m +RESET=\e[0;37;40m +INFO=\e[5;33;40m + base: - $(MAKE) -C deb/ - $(MAKE) -C deb/ CARCH=i686 - $(MAKE) -C archlinux/this/ - $(MAKE) -C archlinux/this/ CARCH=i686 - $(MAKE) -C win32/ - $(MAKE) -C slackware/this/ - $(MAKE) -C slackware/this/ CARCH=i686 - @mv deb/*.deb ./ - @mv archlinux/this/*pkg.tar.xz ./ - @mv win32/*.zip ./ - @mv slackware/this/*.txz ./ + @echo -e "\n$(HEADER)Building Debian packages ...$(RESET)" + @echo -e " $(INFO)=> building 64-bit package$(RESET)" + @$(MAKE) -C deb/ >/dev/null + @echo -e " $(INFO)=> building 32-bit package$(RESET)" + @$(MAKE) -C deb/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null + + @echo -e "\n$(HEADER)Building ArchLinux packages ...$(RESET)" + @echo -e " $(INFO)=> building 64-bit package$(RESET)" + @$(MAKE) -C archlinux/this/ >/dev/null + @echo -e " $(INFO)=> building 32-bit package$(RESET)" + @$(MAKE) -C archlinux/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null + + @echo -e "\n$(HEADER)Building ArchBSD packages ...$(RESET)" + @echo -e " $(INFO)=> building 64-bit package$(RESET)" + @$(MAKE) -C archbsd/this/ >/dev/null + @echo -e " $(INFO)=> building 32-bit package$(RESET)" + @$(MAKE) -C archbsd/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null + + @echo -e "\n$(HEADER)Building Slackware packages ...$(RESET)" + @echo -e " $(INFO)=> building 64-bit package$(RESET)" + @$(MAKE) -C slackware/this/ >/dev/null + @echo -e " $(INFO)=> building 32-bit package$(RESET)" + @$(MAKE) -C slackware/this/ CARCH=i686 OPTIONAL_CFLAGS=-m32 OPTIONAL_LDFLAGS=-m32 >/dev/null + + @echo -e "\n$(HEADER)Building Fedora packages ...$(RESET)" + @echo -e " $(INFO)=> building 64-bit package$(RESET)" + @$(MAKE) -C fedora/this/ >/dev/null + @echo -e "\n\$(HEADER)Building Windows packages ...$(RESET)" + @echo -e " $(INFO)=> building 64-bit package$(RESET)" + @$(MAKE) -C win64/ >/dev/null + @echo -e " $(INFO)=> building 32-bit package$(RESET)" + @$(MAKE) -C win32/ >/dev/null + + @rm -rf pkgs/ + @mkdir pkgs/ + @mv deb/*.deb ./pkgs/ + @mv archlinux/this/*pkg.tar.xz ./pkgs/ + @mv archbsd/this/*pkg.tar.xz ./pkgs/ + @mv win32/*.zip ./pkgs/ + @mv win64/*.zip ./pkgs/ + @mv slackware/this/*.txz ./pkgs/ + @mv fedora/this/*.rpm ./pkgs/ + + @echo -e "\n\n$(HEADER)Completed:$(RESET)" + @find ./pkgs/ -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\|rpm\)" -exec echo -e " $(INFO)=>$(RESET) {}" \; + upload: @echo "APPKEY:76vh3q42hnvmzm3" > dropbox_config @echo "APPSECRET:tmeecht2cmh72xa" >> dropbox_config @@ -31,7 +70,7 @@ upload: @wget -q "http://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" @chmod +x dropbox_uploader.sh @sed -i -e "s/~\/.dropbox_uploader/.\/dropbox_config/g" $$(basename $(DROPBOX)) - @find . -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\)" -exec ./$$(basename $(DROPBOX)) upload {} \; + @find ./pkgs -type f -regex ".*/.*\.\(xz\|deb\|zip\|txz\|rpm\)" -exec ./$$(basename $(DROPBOX)) upload {} \; @rm dropbox_config dropbox_uploader.sh website: @@ -47,11 +86,7 @@ website: @git stash apply clean: - @rm -f *.deb - @rm -f *.pkg.tar.xz - @rm -f *.zip - @rm -f *.gen + @rm -rf pkgs/ @rm -f *.html - @rm -f *.txz all: base upload diff --git a/distro/archbsd/this/Makefile b/distro/archbsd/this/Makefile index afe5514..6bfe650 100644 --- a/distro/archbsd/this/Makefile +++ b/distro/archbsd/this/Makefile @@ -1,4 +1,5 @@ all: $(MAKE) -f ../../archlinux/this/Makefile \ LIBC_DEPEND=libc \ - DESTDIR=distro/archbsd/this + DESTDIR=distro/archbsd/this \ + SUFFIX=archbsd diff --git a/distro/archlinux/this/Makefile b/distro/archlinux/this/Makefile index f224103..91693a4 100644 --- a/distro/archlinux/this/Makefile +++ b/distro/archlinux/this/Makefile @@ -5,8 +5,9 @@ MAJOR := $(shell sed -n -e '/GMQCC_VERSION_MAJOR/{s/.* .* //;p;q;}' $(HEADER)) MINOR := $(shell sed -n -e '/GMQCC_VERSION_MINOR/{s/.* .* //;p;q;}' $(HEADER)) PATCH := $(shell sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER)) PKGREL := 1 +SUFFIX ?= archlinux CARCH := $(shell uname -m) -PKGDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH)-$(PKGREL)-$(CARCH) +PKGDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH)-$(PKGREL)-$(CARCH)-$(SUFFIX) TARCOMP := -J PKG := $(PKGDIR).pkg.tar.xz PKGINFO := $(PKGDIR)/.PKGINFO @@ -15,11 +16,6 @@ CFLAGS := LIBC_DEPEND := glibc -ifneq (, $(findstring i686, $(CARCH))) - CFLAGS += -m32 - LDFLAGS += -m32 -endif - base: $(MAKE) -C $(BASEDIR) clean CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ @@ -45,8 +41,8 @@ base: @bsdtar -C $(PKGDIR) -czf $(PKGDIR)/.MTREE \ --format=mtree \ --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \ - .PKGINFO usr/ - @bsdtar $(TARCOMP) -cvf $(PKG) -C $(PKGDIR)/ .PKGINFO .MTREE usr/ + .PKGINFO usr/ 2>&1 >/dev/null + @bsdtar $(TARCOMP) -cvf $(PKG) -C $(PKGDIR)/ .PKGINFO .MTREE usr/ 2>&1 >/dev/null @rm -rf $(PKGDIR) clean: diff --git a/distro/deb/Makefile b/distro/deb/Makefile index 9752f7a..fefb3e5 100644 --- a/distro/deb/Makefile +++ b/distro/deb/Makefile @@ -35,7 +35,7 @@ base: @tar czf data.tar.gz -C $(DEBDIR)/ . --exclude=DEBIAN @tar czf control.tar.gz -C $(DEBDIR)/DEBIAN/ . @echo 2.0 > debian-binary - @ar r $(DEB) debian-binary control.tar.gz data.tar.gz + @ar r $(DEB) debian-binary control.tar.gz data.tar.gz 2>&1 >/dev/null @rm -rf debian-binary control.tar.gz data.tar.gz $(DEBDIR) clean: diff --git a/distro/fedora/INSTALL b/distro/fedora/INSTALL deleted file mode 100644 index 8540670..0000000 --- a/distro/fedora/INSTALL +++ /dev/null @@ -1,31 +0,0 @@ -File is constantly updated! - -Since Fedora 19 we have this package in main repos. Please use it! - -For install gmqcc do this: -# yum install gmqcc - -For install qcvm do this: -# yum install qcvm - -For install gmqpak do this: -# yum install gmqpak - -To use the spec files in this fedora directory you need the core -development tools , building enviroment for the user, and -the directory structure for it. If you don't already have these, issue -the following commands. - -# yum groupinstall "Development Tools" -# yum install rpmdevtools -$ rm -rf ~/rpmbuild -$ rpmdev-setuptree - -Prepare and build the RPMs. - -$ cp gmqcc.spec ~/rpmbuild/SPECS/ -$ wget https://github.com/graphitemaster/gmqcc/archive/0.3.5.tar.gz -o ~/rpmbuild/SOURCES/gmqcc-0.3.5.tar.gz -$ rpmbuild -ba ~/rpmbuild/SPECS/gmqcc.spec - -Now we have RPMs in ~/rpmbuild/RPMS/ and you can install it via yum. - diff --git a/distro/fedora/gmqcc.spec b/distro/fedora/gmqcc.spec deleted file mode 100644 index f88ecc5..0000000 --- a/distro/fedora/gmqcc.spec +++ /dev/null @@ -1,99 +0,0 @@ -Name: gmqcc -Version: 0.3.5 -Release: 2%{?dist} -Summary: Improved Quake C Compiler -License: MIT -URL: http://graphitemaster.github.io/gmqcc/ -Source0: https://github.com/graphitemaster/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz -# fix build on big endian arches - stdlib.h required for exit() -Patch0: %{name}-0.3.5-stdlib.patch - -# tests fail on big endians -ExclusiveArch: %{ix86} x86_64 %{arm} - -%description -Modern written-from-scratch compiler for the QuakeC language with -support for many common features found in other QC compilers. - -%package -n qcvm -Summary: Standalone QuakeC VM binary executor - -%description -n qcvm -Executor for QuakeC VM binary files created using a QC compiler such -as gmqcc or fteqcc. It provides a small set of built-in functions, and -by default executes the main function if there is one. Some options -useful for debugging are available as well. - -%package -n gmqpak -Summary: Standalone Quake PAK file utility - -%description -n gmqpak -Standalone Quake PAK file utility supporting the extraction of files, -directories, or whole PAKs, as well as the opposite (creation of PAK files). - -%prep -%setup -q -%patch0 -p1 -echo '#!/bin/sh' > ./configure -chmod +x ./configure - -# and for all for all of those switches they increase the runtime of the compile -# making compiles of code slower - -# we don't need compiel time buffer protection, we test with clangs address -# sanatizer and valgrind before releases -%global optflags %(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=2 //') -# there is no exceptions in C -%global optflags %(echo %{optflags} | sed 's/-fexceptions //') -# same with clangs address sanatizer and valgrind testing -%global optflags %(echo %{optflags} | sed 's/-fstack-protector-strong //') -# buffer overflow protection is unrequired since most (if not all) allocations -# happen dynamically and we have our own memory allocator which checks this -# (with valgrind integration), also clangs address santatizer cathes it as -# for grecord-gcc-switches, that just adds pointless information to the binary -# increasing it size -%global optflags %(echo %{optflags} | sed 's/--param=ssp-buffer-size=4 //') - -%build -%configure -make %{?_smp_mflags} - -%install -%make_install PREFIX=%{_prefix} - -%check -make check - -%files -%doc LICENSE README AUTHORS CHANGES TODO -%doc gmqcc.ini.example -%{_mandir}/man1/gmqcc.1* -%{_bindir}/gmqcc - -%files -n qcvm -%doc LICENSE README AUTHORS CHANGES TODO -%{_mandir}/man1/qcvm.1* -%{_bindir}/qcvm - -%files -n gmqpak -%doc LICENSE README AUTHORS CHANGES TODO -%{_mandir}/man1/gmqpak.1* -%{_bindir}/gmqpak - -%changelog -* Sat Nov 16 2013 Dan Horák - 0.3.5-2 -- fix build on big endian arches -- use the standard wildcarded filename for man pages -- and make it Exclusive for little endians because tests fail on big endians - -* Thu Nov 14 2013 Igor Gnatenko - 0.3.5-1 -- 0.3.5 upstream release - -* Thu Sep 26 2013 Igor Gnatenko - 0.3.0-2 -- Optimizing compile flags - -* Fri Sep 20 2013 Igor Gnatenko - 0.3.0-1 -- Update to 0.3.0 (improved new package: gmqpak) - -* Sat Jul 27 2013 Igor Gnatenko - 0.2.9-1 -- Initial release diff --git a/distro/fedora/spec/INSTALL b/distro/fedora/spec/INSTALL new file mode 100644 index 0000000..8540670 --- /dev/null +++ b/distro/fedora/spec/INSTALL @@ -0,0 +1,31 @@ +File is constantly updated! + +Since Fedora 19 we have this package in main repos. Please use it! + +For install gmqcc do this: +# yum install gmqcc + +For install qcvm do this: +# yum install qcvm + +For install gmqpak do this: +# yum install gmqpak + +To use the spec files in this fedora directory you need the core +development tools , building enviroment for the user, and +the directory structure for it. If you don't already have these, issue +the following commands. + +# yum groupinstall "Development Tools" +# yum install rpmdevtools +$ rm -rf ~/rpmbuild +$ rpmdev-setuptree + +Prepare and build the RPMs. + +$ cp gmqcc.spec ~/rpmbuild/SPECS/ +$ wget https://github.com/graphitemaster/gmqcc/archive/0.3.5.tar.gz -o ~/rpmbuild/SOURCES/gmqcc-0.3.5.tar.gz +$ rpmbuild -ba ~/rpmbuild/SPECS/gmqcc.spec + +Now we have RPMs in ~/rpmbuild/RPMS/ and you can install it via yum. + diff --git a/distro/fedora/spec/gmqcc.spec b/distro/fedora/spec/gmqcc.spec new file mode 100644 index 0000000..95fb611 --- /dev/null +++ b/distro/fedora/spec/gmqcc.spec @@ -0,0 +1,96 @@ +Name: gmqcc +Version: 0.3.6 +Release: 2%{?dist} +Summary: Improved Quake C Compiler +License: MIT +URL: http://graphitemaster.github.io/gmqcc/ +Source0: https://github.com/graphitemaster/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz + +# tests fail on big endians +ExclusiveArch: %{ix86} x86_64 %{arm} + +%description +Modern written-from-scratch compiler for the QuakeC language with +support for many common features found in other QC compilers. + +%package -n qcvm +Summary: Standalone QuakeC VM binary executor + +%description -n qcvm +Executor for QuakeC VM binary files created using a QC compiler such +as gmqcc or fteqcc. It provides a small set of built-in functions, and +by default executes the main function if there is one. Some options +useful for debugging are available as well. + +%package -n gmqpak +Summary: Standalone Quake PAK file utility + +%description -n gmqpak +Standalone Quake PAK file utility supporting the extraction of files, +directories, or whole PAKs, as well as the opposite (creation of PAK files). + +%prep +%setup -q +echo '#!/bin/sh' > ./configure +chmod +x ./configure + +# and for all for all of those switches they increase the runtime of the compile +# making compiles of code slower + +# we don't need compile time buffer protection, we test with clang's address +# sanatizer and valgrind before releases +%global optflags %(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=2 //') +# there is no exceptions in C +%global optflags %(echo %{optflags} | sed 's/-fexceptions //') +# same with clangs address sanatizer and valgrind testing +%global optflags %(echo %{optflags} | sed 's/-fstack-protector-strong //') +# buffer overflow protection is unrequired since most (if not all) allocations +# happen dynamically and we have our own memory allocator which checks this +# (with valgrind integration), also clang's address santatizer cathes it as +# for grecord-gcc-switches, that just adds pointless information to the binary +# increasing its size +%global optflags %(echo %{optflags} | sed 's/--param=ssp-buffer-size=4 //') + +%build +%configure +make %{?_smp_mflags} + +%install +%make_install PREFIX=%{_prefix} + +%check +make check + +%files +%doc LICENSE README AUTHORS CHANGES TODO +%doc gmqcc.ini.example +%{_mandir}/man1/gmqcc.1* +%{_bindir}/gmqcc + +%files -n qcvm +%doc LICENSE README AUTHORS CHANGES TODO +%{_mandir}/man1/qcvm.1* +%{_bindir}/qcvm + +%files -n gmqpak +%doc LICENSE README AUTHORS CHANGES TODO +%{_mandir}/man1/gmqpak.1* +%{_bindir}/gmqpak + +%changelog +* Sat Nov 16 2013 Dan Horák - 0.3.5-2 +- fix build on big endian arches +- use the standard wildcarded filename for man pages +- and make it Exclusive for little endians because tests fail on big endians + +* Thu Nov 14 2013 Igor Gnatenko - 0.3.5-1 +- 0.3.5 upstream release + +* Thu Sep 26 2013 Igor Gnatenko - 0.3.0-2 +- Optimizing compile flags + +* Fri Sep 20 2013 Igor Gnatenko - 0.3.0-1 +- Update to 0.3.0 (improved new package: gmqpak) + +* Sat Jul 27 2013 Igor Gnatenko - 0.2.9-1 +- Initial release diff --git a/distro/fedora/this/Makefile b/distro/fedora/this/Makefile new file mode 100644 index 0000000..49b752f --- /dev/null +++ b/distro/fedora/this/Makefile @@ -0,0 +1,21 @@ +BASEDIR := $(CURDIR)/../../.. +HEADER := $(BASEDIR)/gmqcc.h +MAJOR := `sed -n -e '/GMQCC_VERSION_MAJOR/{s/.* .* //;p;q;}' $(HEADER)` +MINOR := `sed -n -e '/GMQCC_VERSION_MINOR/{s/.* .* //;p;q;}' $(HEADER)` +PATCH := `sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER)` +NAME := gmqcc-$(MAJOR).$(MINOR).$(PATCH) +TARFILE := $(NAME).tar.gz + +all: + @mkdir -p ~/rpmbuild/SPECS + @mkdir -p ~/rpmbuild/SOURCES + @cp ../spec/gmqcc.spec ~/rpmbuild/SPECS + @mkdir -p /tmp/$(NAME) + @cp -R $(BASEDIR) /tmp/$(NAME)/ + @cd /tmp && tar -zcf ~/rpmbuild/SOURCES/$(TARFILE) $(NAME)/ + @rm -rf /tmp/$(NAME) + @rpmbuild -ba ../spec/gmqcc.spec 2>&1 >/dev/null + + @mv ~/rpmbuild/RPMS/x86_64/gmqcc*.rpm . 2>/dev/null; true + @mv ~/rpmbuild/RPMS/x86_64/qcvm*.rpm . 2>/dev/null; true + @mv ~/rpmbuild/RPMS/x86_64/gmqpak*.rpm . 2>/dev/null; true diff --git a/distro/win32/Makefile b/distro/win32/Makefile index 62bb220..20f580c 100644 --- a/distro/win32/Makefile +++ b/distro/win32/Makefile @@ -6,8 +6,8 @@ PATCH := `sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER)` BINDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH) base: - $(MAKE) CC=i486-mingw32-gcc UNAME=MINGW32 -C $(BASEDIR) clean - $(MAKE) CC=i486-mingw32-gcc UNAME=MINGW32 -C $(BASEDIR) DESTDIR=distro/win32/$(BINDIR) PREFIX=/ strip install + $(MAKE) CC=i686-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) clean + $(MAKE) CC=i686-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) DESTDIR=distro/win32/$(BINDIR) PREFIX=/ strip install @mkdir -p $(BINDIR)/doc @groff -mandoc $(BINDIR)/man1/gmqpak.1 | ps2pdf - $(BINDIR)/doc/gmqpak.pdf @groff -mandoc $(BINDIR)/man1/qcvm.1 | ps2pdf - $(BINDIR)/doc/qcvm.pdf diff --git a/distro/win64/Makefile b/distro/win64/Makefile new file mode 100644 index 0000000..f45f351 --- /dev/null +++ b/distro/win64/Makefile @@ -0,0 +1,22 @@ +BASEDIR := ../.. +HEADER := $(BASEDIR)/gmqcc.h +MAJOR := `sed -n -e '/GMQCC_VERSION_MAJOR/{s/.* .* //;p;q;}' $(HEADER)` +MINOR := `sed -n -e '/GMQCC_VERSION_MINOR/{s/.* .* //;p;q;}' $(HEADER)` +PATCH := `sed -n -e '/GMQCC_VERSION_PATCH/{s/.* .* //;p;q;}' $(HEADER)` +BINDIR := gmqcc-$(MAJOR).$(MINOR).$(PATCH) + +base: + $(MAKE) CC=x86_64-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) clean + $(MAKE) CC=x86_64-w64-mingw32-gcc UNAME=MINGW -C $(BASEDIR) DESTDIR=distro/win64/$(BINDIR) PREFIX=/ strip install + @mkdir -p $(BINDIR)/doc + @groff -mandoc $(BINDIR)/man1/gmqpak.1 | ps2pdf - $(BINDIR)/doc/gmqpak.pdf + @groff -mandoc $(BINDIR)/man1/qcvm.1 | ps2pdf - $(BINDIR)/doc/qcvm.pdf + @groff -mandoc $(BINDIR)/man1/gmqcc.1 | ps2pdf - $(BINDIR)/doc/gmqcc.pdf + @rm -rf $(BINDIR)/man1/ + @zip -r $(BINDIR)-win64.zip $(BINDIR) + @rm -rf $(BINDIR) +clean: + $(MAKE) -C $(BASEDIR) clean + @rm -f *.zip + +all: base diff --git a/ftepp.c b/ftepp.c index 44c1ebb..c574f03 100644 --- a/ftepp.c +++ b/ftepp.c @@ -763,6 +763,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param lex_file *inlex; bool old_inmacro; + bool strip = false; int nextok; @@ -827,6 +828,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param if (nextok == '#') { /* raw concatenation */ ++o; + strip = true; break; } if ( (nextok == TOKEN_IDENT || @@ -835,6 +837,7 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param macro_params_find(macro, macro->output[o+1]->value, &pi)) { ++o; + ftepp_stringify(ftepp, ¶ms[pi]); break; } @@ -845,7 +848,14 @@ static bool ftepp_macro_expand(ftepp_t *ftepp, ppmacro *macro, macroparam *param ftepp_out(ftepp, "\n", false); break; default: - ftepp_out(ftepp, out->value, false); + buffer = out->value; + if (vec_size(macro->output) > o + 1 && macro->output[o+1]->token == '#') + buffer++; + if (strip) { + while (util_isspace(*buffer)) buffer++; + strip = false; + } + ftepp_out(ftepp, buffer, false); break; } } diff --git a/include.mk b/include.mk index efb4a89..23c3fb9 100644 --- a/include.mk +++ b/include.mk @@ -1,6 +1,5 @@ # default directories and paths DESTDIR := -OPTIONAL:= PREFIX := /usr/local BINDIR := $(PREFIX)/bin DATADIR := $(PREFIX)/share @@ -16,6 +15,10 @@ LIBS += -lm #common objects COMMON = ansi.o util.o hash.o stat.o fs.o opts.o conout.o +#optional flags +OPTIONAL_CFLAGS := +OPTIONAL_LDFLAGS := + #objects OBJ_C = $(COMMON) main.o lexer.o parser.o code.o ast.o ir.o ftepp.o utf8.o correct.o fold.o intrin.o OBJ_P = $(COMMON) pak.o diff --git a/tests/pmacros.qc b/tests/pmacros.qc index 1ec0780..9bac539 100644 --- a/tests/pmacros.qc +++ b/tests/pmacros.qc @@ -26,7 +26,7 @@ # define ALPHA(SEL) ALPHA_##SEL -# define ABC ALPHA(a)##ALPHA(b)##ALPHA(c) +# define ABC ALPHA(a)ALPHA(b)ALPHA(c) void() main = { if (ABC == "abc") diff --git a/tests/ppcat.qc b/tests/ppcat.qc index ca92060..dc28269 100644 --- a/tests/ppcat.qc +++ b/tests/ppcat.qc @@ -8,6 +8,6 @@ REDIR(CAT(hello, world), CAT(world, hello)) SCONS(hello, world) #define FOO(X) X##X -#define BAR(X) FOO(X)##FOO(X) +#define BAR(X) FOO(X)FOO(X) -REDIR(BAR(hello), BAR(world)) +REDIR(BAR(hello),BAR(world))