From 5896a4d65de68c5e29b5566234e71e1c288df08d Mon Sep 17 00:00:00 2001 From: Bryan Jurish Date: Fri, 23 Jan 2009 21:26:14 +0000 Subject: + added locale/ : basic C99 locale support svn path=/trunk/externals/moocow/; revision=10605 --- locale/src/Makefile.am | 132 +++++++++ locale/src/Makefile.in | 683 ++++++++++++++++++++++++++++++++++++++++++++++ locale/src/config.h.in | 92 +++++++ locale/src/locale-help.pd | 33 +++ locale/src/locale-test.pd | 111 ++++++++ locale/src/locale.c | 452 ++++++++++++++++++++++++++++++ 6 files changed, 1503 insertions(+) create mode 100644 locale/src/Makefile.am create mode 100644 locale/src/Makefile.in create mode 100644 locale/src/config.h.in create mode 100644 locale/src/locale-help.pd create mode 100644 locale/src/locale-test.pd create mode 100644 locale/src/locale.c (limited to 'locale/src') diff --git a/locale/src/Makefile.am b/locale/src/Makefile.am new file mode 100644 index 0000000..8eb938e --- /dev/null +++ b/locale/src/Makefile.am @@ -0,0 +1,132 @@ +# File: ./src/Makefile.am +# Package: rawfile +# Description: +# + src-level automake file +# +# Process this file with Automake to create Makefile.in. +#----------------------------------------------------------------------- + +#----------------------------------------------------------------------- +# Options & Subdirectories +#----------------------------------------------------------------------- + +## --- recursion subdirectories +#SUBDIRS = + +## --- pseudo-deps for '.SUFFIXES' +SUFFIXES = .@PDEXT@ + +#----------------------------------------------------------------------- +# Flags and variables +#----------------------------------------------------------------------- +PDEXT = @PDEXT@ +EXEEXT = .@PDEXT@ + +#----------------------------------------------------------------------- +# pd externals (hacked _PROGRAMS target) +#----------------------------------------------------------------------- + +## --- externals +pdexterns_PROGRAMS = @PD_OBJECT_EXTERNALS@ + +## --- possible externals +EXTRA_PROGRAMS = \ + locale + +## --- patches +pdexterns_DATA = + +## --- documentation +pddoc_DATA = locale-help.pd + + +#----------------------------------------------------------------------- +# sources +#----------------------------------------------------------------------- + +locale_SOURCES = \ + locale.c + +#----------------------------------------------------------------------- +# external compilation : flags +#----------------------------------------------------------------------- +DEFS = @DEFS@ +AFLAGS = @AFLAGS@ +DFLAGS = @DFLAGS@ +IFLAGS = @IFLAGS@ +LFLAGS = @LFLAGS@ +OFLAGS = @OFLAGS@ +WFLAGS = -Wall -Winline + +AM_CPPFLAGS = $(IFLAGS) $(DFLAGS) +AM_CFLAGS = $(OFLAGS) $(WFLAGS) $(AFLAGS) + +locale_LDFLAGS = $(LFLAGS) +#locale_LDADD = + +#----------------------------------------------------------------------- +# Variables: cleanup +#----------------------------------------------------------------------- +## --- mostlyclean: built by 'make' & commonly rebuilt +#MOSTLYCLEANFILES = + +## --- clean: built by 'make' +CLEANFILES = *.$(PDEXT) + +## --- distclean: built by 'configure' +DISTCLEANFILES = \ + config.log \ + config.cache \ + config.status + +## -- maintainerclean: built by maintainer / by hand +MAINTAINERCLEANFILES = *~ \ + $(PODS:.pod=.txt) \ + Makefile Makefile.in \ + aclocal.m4 \ + configure \ + install-sh \ + stamp-h.in \ + config.h.in + +maintainer-clean-local: + rm -rf autom4te.cache + +#CVSCLEAN_SUBDIRS = $(SUBDIRS) + +#CVSCLEANFILES = Makefile.in Makefile + + +#----------------------------------------------------------------------- +# Variables: distribution +#----------------------------------------------------------------------- + +## --- extra distribution files +EXTRA_DIST = \ + $(pddoc_DATA) \ + $(pdexterns_DATA) + +## --- recursion subdirectories for 'make dist' +DIST_SUBDIRS = $(SUBDIRS) + +## --- dist-hook: when another 'Makefile.am' is overkill +#DISTHOOK_DIRS = foo +#DISTHOOK_FILES = foo/bar.txt foo/baz.txt +#dist-hook: +# for d in $(DISTHOOK_DIRS); do\ +# mkdir -p $(distdir)/$$d ;\ +# done +# for f in $(DISTHOOK_FILES); do\ +# cp -p $(srcdir)/$$f $(distdir)/$$f ;\ +# done + +#dist-bz2: dist-bzip2 ; + + +#----------------------------------------------------------------------- +# Rules: cleanup +#----------------------------------------------------------------------- +.PHONY: cvsclean cvsclean-hook + +cvsclean: maintainer-clean ; + diff --git a/locale/src/Makefile.in b/locale/src/Makefile.in new file mode 100644 index 0000000..a348f37 --- /dev/null +++ b/locale/src/Makefile.in @@ -0,0 +1,683 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# File: ./src/Makefile.am +# Package: rawfile +# Description: +# + src-level automake file +# +# Process this file with Automake to create Makefile.in. +#----------------------------------------------------------------------- + +#----------------------------------------------------------------------- +# Options & Subdirectories +#----------------------------------------------------------------------- + +#SUBDIRS = + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +pdexterns_PROGRAMS = @PD_OBJECT_EXTERNALS@ +EXTRA_PROGRAMS = locale$(EXEEXT) +subdir = src +SUBDIRS = +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(pdexternsdir)" "$(DESTDIR)$(pddocdir)" \ + "$(DESTDIR)$(pdexternsdir)" +pdexternsPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(pdexterns_PROGRAMS) +am_locale_OBJECTS = locale.$(OBJEXT) +locale_OBJECTS = $(am_locale_OBJECTS) +locale_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I. +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(locale_SOURCES) +DIST_SOURCES = $(locale_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +pddocDATA_INSTALL = $(INSTALL_DATA) +pdexternsDATA_INSTALL = $(INSTALL_DATA) +DATA = $(pddoc_DATA) $(pdexterns_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AFLAGS = @AFLAGS@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUGREPORT = @BUGREPORT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEBUG = @DEBUG@ + +#----------------------------------------------------------------------- +# external compilation : flags +#----------------------------------------------------------------------- +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DFLAGS = @DFLAGS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EXEEXT = .@PDEXT@ +IFLAGS = @IFLAGS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LFLAGS = @LFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +OFLAGS = @OFLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ + +#----------------------------------------------------------------------- +# Flags and variables +#----------------------------------------------------------------------- +PDEXT = @PDEXT@ +PD_OBJECT_EXTERNALS = @PD_OBJECT_EXTERNALS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +WFLAGS = -Wall -Winline +ac_ct_CC = @ac_ct_CC@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pddir = @pddir@ +pddocdir = @pddocdir@ +pdexternsdir = @pdexternsdir@ +pdfdir = @pdfdir@ +pdincludedir = @pdincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +SUFFIXES = .@PDEXT@ +pdexterns_DATA = +pddoc_DATA = locale-help.pd + +#----------------------------------------------------------------------- +# sources +#----------------------------------------------------------------------- +locale_SOURCES = \ + locale.c + +AM_CPPFLAGS = $(IFLAGS) $(DFLAGS) +AM_CFLAGS = $(OFLAGS) $(WFLAGS) $(AFLAGS) +locale_LDFLAGS = $(LFLAGS) +#locale_LDADD = + +#----------------------------------------------------------------------- +# Variables: cleanup +#----------------------------------------------------------------------- +#MOSTLYCLEANFILES = +CLEANFILES = *.$(PDEXT) +DISTCLEANFILES = \ + config.log \ + config.cache \ + config.status + +MAINTAINERCLEANFILES = *~ \ + $(PODS:.pod=.txt) \ + Makefile Makefile.in \ + aclocal.m4 \ + configure \ + install-sh \ + stamp-h.in \ + config.h.in + + +#CVSCLEAN_SUBDIRS = $(SUBDIRS) + +#CVSCLEANFILES = Makefile.in Makefile + +#----------------------------------------------------------------------- +# Variables: distribution +#----------------------------------------------------------------------- +EXTRA_DIST = \ + $(pddoc_DATA) \ + $(pdexterns_DATA) + +DIST_SUBDIRS = $(SUBDIRS) +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .@PDEXT@ .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status src/config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-pdexternsPROGRAMS: $(pdexterns_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(pdexternsdir)" || $(mkdir_p) "$(DESTDIR)$(pdexternsdir)" + @list='$(pdexterns_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(pdexternsPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(pdexternsdir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(pdexternsPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(pdexternsdir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-pdexternsPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(pdexterns_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(pdexternsdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pdexternsdir)/$$f"; \ + done + +clean-pdexternsPROGRAMS: + -test -z "$(pdexterns_PROGRAMS)" || rm -f $(pdexterns_PROGRAMS) +locale$(EXEEXT): $(locale_OBJECTS) $(locale_DEPENDENCIES) + @rm -f locale$(EXEEXT) + $(LINK) $(locale_LDFLAGS) $(locale_OBJECTS) $(locale_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locale.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: +install-pddocDATA: $(pddoc_DATA) + @$(NORMAL_INSTALL) + test -z "$(pddocdir)" || $(mkdir_p) "$(DESTDIR)$(pddocdir)" + @list='$(pddoc_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pddocDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pddocdir)/$$f'"; \ + $(pddocDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pddocdir)/$$f"; \ + done + +uninstall-pddocDATA: + @$(NORMAL_UNINSTALL) + @list='$(pddoc_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pddocdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pddocdir)/$$f"; \ + done +install-pdexternsDATA: $(pdexterns_DATA) + @$(NORMAL_INSTALL) + test -z "$(pdexternsdir)" || $(mkdir_p) "$(DESTDIR)$(pdexternsdir)" + @list='$(pdexterns_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pdexternsDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pdexternsdir)/$$f'"; \ + $(pdexternsDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pdexternsdir)/$$f"; \ + done + +uninstall-pdexternsDATA: + @$(NORMAL_UNINSTALL) + @list='$(pdexterns_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pdexternsdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pdexternsdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) $(DATA) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(pdexternsdir)" "$(DESTDIR)$(pddocdir)" "$(DESTDIR)$(pdexternsdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-generic clean-pdexternsPROGRAMS mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-pddocDATA install-pdexternsDATA \ + install-pdexternsPROGRAMS + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic \ + maintainer-clean-local + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am uninstall-pddocDATA \ + uninstall-pdexternsDATA uninstall-pdexternsPROGRAMS + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-pdexternsPROGRAMS clean-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-hdr distclean-recursive \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-pddocDATA install-pdexternsDATA \ + install-pdexternsPROGRAMS install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-local \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am \ + uninstall-pddocDATA uninstall-pdexternsDATA \ + uninstall-pdexternsPROGRAMS + + +maintainer-clean-local: + rm -rf autom4te.cache + +#DISTHOOK_DIRS = foo +#DISTHOOK_FILES = foo/bar.txt foo/baz.txt +#dist-hook: +# for d in $(DISTHOOK_DIRS); do\ +# mkdir -p $(distdir)/$$d ;\ +# done +# for f in $(DISTHOOK_FILES); do\ +# cp -p $(srcdir)/$$f $(distdir)/$$f ;\ +# done + +#dist-bz2: dist-bzip2 ; + +#----------------------------------------------------------------------- +# Rules: cleanup +#----------------------------------------------------------------------- +.PHONY: cvsclean cvsclean-hook + +cvsclean: maintainer-clean ; +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/locale/src/config.h.in b/locale/src/config.h.in new file mode 100644 index 0000000..40f0f0d --- /dev/null +++ b/locale/src/config.h.in @@ -0,0 +1,92 @@ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the declaration of `LC_ADDRESS', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_ADDRESS + +/* Define to 1 if you have the declaration of `LC_ALL', and to 0 if you don't. + */ +#undef HAVE_DECL_LC_ALL + +/* Define to 1 if you have the declaration of `LC_COLLATE', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_COLLATE + +/* Define to 1 if you have the declaration of `LC_CTYPE', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_CTYPE + +/* Define to 1 if you have the declaration of `LC_IDENTIFICATION', and to 0 if + you don't. */ +#undef HAVE_DECL_LC_IDENTIFICATION + +/* Define to 1 if you have the declaration of `LC_MEASUREMENT', and to 0 if + you don't. */ +#undef HAVE_DECL_LC_MEASUREMENT + +/* Define to 1 if you have the declaration of `LC_MESSAGES', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_MESSAGES + +/* Define to 1 if you have the declaration of `LC_MONETARY', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_MONETARY + +/* Define to 1 if you have the declaration of `LC_NAME', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_NAME + +/* Define to 1 if you have the declaration of `LC_NUMERIC', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_NUMERIC + +/* Define to 1 if you have the declaration of `LC_PAPER', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_PAPER + +/* Define to 1 if you have the declaration of `LC_TELEPHONE', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_TELEPHONE + +/* Define to 1 if you have the declaration of `LC_TIME', and to 0 if you + don't. */ +#undef HAVE_DECL_LC_TIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Date this external was configured */ +#undef PDMOOEXT_DATE + +/* User who configured this external */ +#undef PDMOOEXT_USER + +/* Define this to include debugging code for the 'rawfile' external. */ +#undef RAWFILE_DEBUG + +/* Version number of package */ +#undef VERSION diff --git a/locale/src/locale-help.pd b/locale/src/locale-help.pd new file mode 100644 index 0000000..20da938 --- /dev/null +++ b/locale/src/locale-help.pd @@ -0,0 +1,33 @@ +#N canvas 50 16 604 376 10; +#X text 56 7 locale : access to C99-style localization; +#X obj 41 298 locale; +#X obj 41 320 print locale-out; +#X text 262 342 Bryan Jurish ; +#X msg 41 48 set; +#X text 222 49 "set" : initialize locale from environment variables +; +#X msg 47 68 set LC_CTYPE de_DE.UTF-8; +#X msg 50 107 get; +#X msg 56 127 get LC_CTYPE; +#X text 226 128 "get CATEGORY" : get value for CATEGORY; +#X text 226 107 "get" : symbol representing current locale; +#X msg 66 193 reset; +#X text 226 189 "reset" : alias for "set LC_ALL C"; +#X text 130 216 WARNING:; +#X text 150 229 Injudicious use of "set" can cause bizarre and unexpected +results. In particular \, setting LC_NUMERIC (possibly via LC_ALL or +LANG) to a locale whose floats are comma-separated rather than dot-separated +(e.g. de_DE) can confuse Pd's underlying float-parsing mechanism.; +#X msg 66 173 bang; +#X text 226 173 "bang" : alias for "set"; +#X text 224 69 "set CATEGORY VALUE" : set CATEGORY to VALUE; +#X msg 64 151 which; +#X text 226 153 "which" : list supported categories; +#X connect 1 0 2 0; +#X connect 4 0 1 0; +#X connect 6 0 1 0; +#X connect 7 0 1 0; +#X connect 8 0 1 0; +#X connect 11 0 1 0; +#X connect 15 0 1 0; +#X connect 18 0 1 0; diff --git a/locale/src/locale-test.pd b/locale/src/locale-test.pd new file mode 100644 index 0000000..6542d82 --- /dev/null +++ b/locale/src/locale-test.pd @@ -0,0 +1,111 @@ +#N canvas 626 4 605 546 10; +#X obj 54 288 locale; +#X obj 36 380 print locale-out; +#X msg 149 255 set; +#X msg 157 281 bang; +#X msg 141 231 set \$1 \$2; +#N canvas 0 0 450 300 setmsg 0; +#X obj 22 48 symbol; +#X obj 22 10 inlet; +#X obj 103 12 inlet; +#X obj 103 52 symbol; +#X obj 42 90 pack s s; +#X obj 74 138 print setmsg; +#X obj 46 166 outlet; +#X connect 0 0 4 0; +#X connect 1 0 0 0; +#X connect 2 0 3 0; +#X connect 3 0 4 1; +#X connect 4 0 5 0; +#X connect 4 0 6 0; +#X restore 140 206 pd setmsg; +#X msg 140 45 LC_ALL; +#X msg 140 65 LC_CTYPE; +#X msg 140 85 LC_PAPER; +#X obj 139 26 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X msg 243 69 en_US.UTF-8; +#X msg 243 91 en_US.ISO-8859-1; +#X msg 241 23 C; +#X msg 43 233 get \$1; +#X msg 55 253 get; +#X msg 44 53 LC_ALL; +#X msg 44 73 LC_CTYPE; +#X msg 44 93 LC_PAPER; +#X obj 43 34 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#N canvas 0 0 450 300 getmsg 0; +#X obj 22 48 symbol; +#X obj 22 10 inlet; +#X obj 46 166 outlet; +#X obj 58 76 print getmsg; +#X connect 0 0 3 0; +#X connect 0 0 2 0; +#X connect 1 0 0 0; +#X restore 44 210 pd getmsg; +#X symbolatom 64 351 10 0 0 0 - - -; +#X symbolatom 170 349 32 0 0 0 - - -; +#X obj 64 329 unpack s s; +#X obj 64 309 list; +#X obj 170 373 symbol2list; +#X obj 282 375 loadbang; +#X msg 282 399 59; +#X obj 282 422 makefilename %c; +#X obj 170 400 drip; +#X obj 170 424 symbol2list =; +#X obj 170 448 print lc_var; +#X msg 243 45 en_DK.UTF-8; +#X msg 245 115 de_DE.UTF-8; +#X msg 245 135 de_DE.ISO-8859-1; +#X msg 141 107 LC_TIME; +#X msg 44 115 LC_TIME; +#X obj 387 246 sprintf %f; +#X floatatom 385 218 5 0 0 0 - - -; +#X obj 387 276 print float; +#X msg 382 189 42; +#X msg 44 133 LC_NUMERIC; +#X msg 140 129 LC_NUMERIC; +#X msg 202 253 reset; +#X msg 206 279 which; +#X connect 0 0 1 0; +#X connect 0 0 23 0; +#X connect 2 0 0 0; +#X connect 3 0 0 0; +#X connect 4 0 0 0; +#X connect 5 0 4 0; +#X connect 6 0 5 0; +#X connect 7 0 5 0; +#X connect 8 0 5 0; +#X connect 9 0 5 0; +#X connect 10 0 5 1; +#X connect 11 0 5 1; +#X connect 12 0 5 1; +#X connect 13 0 0 0; +#X connect 14 0 0 0; +#X connect 15 0 19 0; +#X connect 16 0 19 0; +#X connect 17 0 19 0; +#X connect 18 0 19 0; +#X connect 19 0 13 0; +#X connect 21 0 24 0; +#X connect 22 0 20 0; +#X connect 22 1 21 0; +#X connect 23 0 22 0; +#X connect 24 0 28 0; +#X connect 25 0 26 0; +#X connect 26 0 27 0; +#X connect 27 0 24 1; +#X connect 28 0 29 0; +#X connect 29 0 30 0; +#X connect 31 0 5 1; +#X connect 32 0 5 1; +#X connect 33 0 5 1; +#X connect 34 0 5 0; +#X connect 35 0 19 0; +#X connect 36 0 38 0; +#X connect 37 0 36 0; +#X connect 39 0 37 0; +#X connect 40 0 19 0; +#X connect 41 0 5 0; +#X connect 42 0 0 0; +#X connect 43 0 0 0; diff --git a/locale/src/locale.c b/locale/src/locale.c new file mode 100644 index 0000000..82938bb --- /dev/null +++ b/locale/src/locale.c @@ -0,0 +1,452 @@ +/* -*- Mode: C -*- */ +/*=============================================================================*\ + * File: locale.c + * Author: Bryan Jurish + * Description: general directory access object + * + * Copyright (c) 2009 Bryan Jurish. + * + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See file LICENSE for further informations on licensing terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *=============================================================================*/ + +#include +#include +#include + +#include + +/* black magic */ +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_WCHAR_H +# include +#endif +#ifdef HAVE_LOCALE_H +# include +#endif + +/*-------------------------------------------------------------------- + * DEBUG + *--------------------------------------------------------------------*/ +/*#define LOCALE_DEBUG 1*/ + +/*-------------------------------------------------------------------- + * "unused" pragma + */ +#ifdef __GNUC__ +# define MOO_UNUSED __attribute__((unused)) +#else +# define MOO_UNUSED +#endif + +/*===================================================================== + * Constants + *=====================================================================*/ + +/*===================================================================== + * Structures and Types + *=====================================================================*/ + +static char *locale_banner = + "\nlocale: version " PACKAGE_VERSION " by Bryan Jurish : C99 locale support\n" + "locale: compiled by " PDMOOEXT_USER " on " PDMOOEXT_DATE ; + +static t_class *locale_class; + +typedef struct _locale +{ + t_object x_obj; + t_outlet *x_outlet; //-- data outlet +} t_locale; + +/*===================================================================== + * Constants + *=====================================================================*/ + +/*-- LC_* constants defined in locale.h (debian libc6-dev 2.7-5)-- + +LC_ALL +LC_CTYPE +LC_NUMERIC +LC_TIME +LC_COLLATE +LC_MONETARY +LC_MESSAGES +LC_PAPER +LC_NAME +LC_ADDRESS +LC_TELEPHONE +LC_MEASUREMENT +LC_IDENTIFICATION + +*/ + +//-- Constants: categories +#if HAVE_DECL_LC_ALL + static t_symbol *sp_LC_ALL; +#endif +#if HAVE_DECL_LC_CTYPE + static t_symbol *sp_LC_CTYPE; +#endif +#if HAVE_DECL_LC_NUMERIC + static t_symbol *sp_LC_NUMERIC; +#endif +#if HAVE_DECL_LC_TIME + static t_symbol *sp_LC_TIME; +#endif +#if HAVE_DECL_LC_COLLATE + static t_symbol *sp_LC_COLLATE; +#endif +#if HAVE_DECL_LC_MONETARY + static t_symbol *sp_LC_MONETARY; +#endif +#if HAVE_DECL_LC_MESSAGES + static t_symbol *sp_LC_MESSAGES; +#endif +#if HAVE_DECL_LC_PAPER + static t_symbol *sp_LC_PAPER; +#endif +#if HAVE_DECL_LC_NAME + static t_symbol *sp_LC_NAME; +#endif +#if HAVE_DECL_LC_ADDRESS + static t_symbol *sp_LC_ADDRESS; +#endif +#if HAVE_DECL_LC_TELEPHONE + static t_symbol *sp_LC_TELEPHONE; +#endif +#if HAVE_DECL_LC_MEASUREMENT + static t_symbol *sp_LC_MEASUREMENT; +#endif +#if HAVE_DECL_LC_IDENTIFICATION + static t_symbol *sp_LC_IDENTIFICATION; +#endif + +/*===================================================================== + * Utilities + *=====================================================================*/ + +/*-------------------------------------------------------------------- + * sym2cat(symbol) + */ +static int sym2cat(t_object *obj, t_symbol *sym) +{ + if (sym==sp_LC_ALL || sym==&s_) return LC_ALL; +#if HAVE_DECL_LC_CTYPE + else if (sym==sp_LC_CTYPE) return LC_CTYPE; +#endif +#if HAVE_DECL_LC_NUMERIC + else if (sym==sp_LC_NUMERIC) return LC_NUMERIC; +#endif +#if HAVE_DECL_LC_TIME + else if (sym==sp_LC_TIME) return LC_TIME; +#endif +#if HAVE_DECL_LC_COLLATE + else if (sym==sp_LC_COLLATE) return LC_COLLATE; +#endif +#if HAVE_DECL_LC_MONETARY + else if (sym==sp_LC_MONETARY) return LC_MONETARY; +#endif +#if HAVE_DECL_LC_MESSAGES + else if (sym==sp_LC_MESSAGES) return LC_MESSAGES; +#endif +#if HAVE_DECL_LC_PAPER + else if (sym==sp_LC_PAPER) return LC_PAPER; +#endif +#if HAVE_DECL_LC_NAME + else if (sym==sp_LC_NAME) return LC_NAME; +#endif +#if HAVE_DECL_LC_ADDRESS + else if (sym==sp_LC_ADDRESS) return LC_ADDRESS; +#endif +#if HAVE_DECL_LC_TELEPHONE + else if (sym==sp_LC_TELEPHONE) return LC_TELEPHONE; +#endif +#if HAVE_DECL_LC_MEASUREMENT + else if (sym==sp_LC_MEASUREMENT) return LC_MEASUREMENT; +#endif +#if HAVE_DECL_LC_IDENTIFICATION + else if (sym==sp_LC_IDENTIFICATION) return LC_IDENTIFICATION; +#endif +#if HAVE_DECL_LC_FOOBAR + else if (sym==sp_LC_FOOBAR) return LC_FOOBAR; +#endif + pd_error(obj, ": sym2cat() could not find locale category for symbol '%s', using LC_ALL", sym->s_name); + return LC_ALL; +} + +/*-------------------------------------------------------------------- + * cat2sym(cat) + */ +MOO_UNUSED +static t_symbol *cat2sym(t_object *obj, int cat) +{ + switch (cat) { +#if HAVE_DECL_LC_ALL + case LC_ALL: return sp_LC_ALL; break; +#endif +#if HAVE_DECL_LC_CTYPE + case LC_CTYPE: return sp_LC_CTYPE; break; +#endif +#if HAVE_DECL_LC_NUMERIC + case LC_NUMERIC: return sp_LC_NUMERIC; break; +#endif +#if HAVE_DECL_LC_TIME + case LC_TIME: return sp_LC_TIME; break; +#endif +#if HAVE_DECL_LC_COLLATE + case LC_COLLATE: return sp_LC_COLLATE; break; +#endif +#if HAVE_DECL_LC_MONETARY + case LC_MONETARY: return sp_LC_MONETARY; break; +#endif +#if HAVE_DECL_LC_MESSAGES + case LC_MESSAGES: return sp_LC_MESSAGES; break; +#endif +#if HAVE_DECL_LC_PAPER + case LC_PAPER: return sp_LC_PAPER; break; +#endif +#if HAVE_DECL_LC_NAME + case LC_NAME: return sp_LC_NAME; break; +#endif +#if HAVE_DECL_LC_ADDRESS + case LC_ADDRESS: return sp_LC_ADDRESS; break; +#endif +#if HAVE_DECL_LC_TELEPHONE + case LC_TELEPHONE: return sp_LC_TELEPHONE; break; +#endif +#if HAVE_DECL_LC_MEASUREMENT + case LC_MEASUREMENT: return sp_LC_MEASUREMENT; break; +#endif +#if HAVE_DECL_LC_IDENTIFICATION + case LC_IDENTIFICATION: return sp_LC_IDENTIFICATION; break; +#endif + default: break; + } + pd_error(obj, ": cat2sym() unknown locale category '%d'", cat); + return &s_; +} + +/*===================================================================== + * Methods + *=====================================================================*/ + +/*-------------------------------------------------------------------- + * bang + */ +static void locale_bang(t_locale *x) +{ + setlocale(LC_ALL,""); +} + +/*-------------------------------------------------------------------- + * get , get CATEGORY + */ +static void locale_get(t_locale *x, t_symbol *catsym) +{ + int cat = sym2cat((t_object*)x, catsym); + char *val; + t_atom valatom; + val = setlocale(cat, NULL); + if (val) { + SETSYMBOL(&valatom,gensym(val)); + } else { + SETSYMBOL(&valatom,&s_); + } + outlet_anything(x->x_outlet, catsym, 1, &valatom); +} + + +/*-------------------------------------------------------------------- + * set , set CATEGORY VALUE + */ +static void locale_set(t_locale *x, t_symbol *catsym, t_symbol *valsym) +{ + int cat; + if (catsym==&s_ && valsym==&s_) { locale_bang(x); return; } + cat = sym2cat((t_object*)x,catsym); + setlocale(cat,valsym->s_name); +} + +/*-------------------------------------------------------------------- + * reset -> set LC_ALL C + */ +static void locale_reset(t_locale *x) +{ + setlocale(LC_ALL,"C"); +} + +/*-------------------------------------------------------------------- + * which + */ +static void locale_which(t_locale *x) +{ +#if HAVE_DECL_LC_ALL + outlet_symbol(x->x_outlet,sp_LC_ALL); +#endif +#if HAVE_DECL_LC_CTYPE + outlet_symbol(x->x_outlet,sp_LC_CTYPE); +#endif +#if HAVE_DECL_LC_NUMERIC + outlet_symbol(x->x_outlet,sp_LC_NUMERIC); +#endif +#if HAVE_DECL_LC_TIME + outlet_symbol(x->x_outlet,sp_LC_TIME); +#endif +#if HAVE_DECL_LC_COLLATE + outlet_symbol(x->x_outlet,sp_LC_COLLATE); +#endif +#if HAVE_DECL_LC_MONETARY + outlet_symbol(x->x_outlet,sp_LC_MONETARY); +#endif +#if HAVE_DECL_LC_MESSAGES + outlet_symbol(x->x_outlet,sp_LC_MESSAGES); +#endif +#if HAVE_DECL_LC_PAPER + outlet_symbol(x->x_outlet,sp_LC_PAPER); +#endif +#if HAVE_DECL_LC_NAME + outlet_symbol(x->x_outlet,sp_LC_NAME); +#endif +#if HAVE_DECL_LC_ADDRESS + outlet_symbol(x->x_outlet,sp_LC_ADDRESS); +#endif +#if HAVE_DECL_LC_TELEPHONE + outlet_symbol(x->x_outlet,sp_LC_TELEPHONE); +#endif +#if HAVE_DECL_LC_MEASUREMENT + outlet_symbol(x->x_outlet,sp_LC_MEASUREMENT); +#endif +#if HAVE_DECL_LC_IDENTIFICATION + outlet_symbol(x->x_outlet,sp_LC_IDENTIFICATION); +#endif +} + + +/*-------------------------------------------------------------------- + * new + */ +static void *locale_new(void) +{ + t_locale *x = (t_locale *)pd_new(locale_class); + x->x_outlet = outlet_new(&x->x_obj, &s_anything); + return (void *)x; +} + +/*-------------------------------------------------------------------- + * free + */ +static void locale_free(t_locale *x) +{ + outlet_free(x->x_outlet); + return; +} + +/*===================================================================== + * Setup + *=====================================================================*/ + +/*-------------------------------------------------------------------- + * setup: symbols + */ +static void locale_setup_constants(void) +{ +#if HAVE_DECL_LC_ALL + sp_LC_ALL = gensym("LC_ALL"); +#endif +#if HAVE_DECL_LC_CTYPE + sp_LC_CTYPE = gensym("LC_CTYPE"); +#endif +#if HAVE_DECL_LC_NUMERIC + sp_LC_NUMERIC = gensym("LC_NUMERIC"); +#endif +#if HAVE_DECL_LC_TIME + sp_LC_TIME = gensym("LC_TIME"); +#endif +#if HAVE_DECL_LC_COLLATE + sp_LC_COLLATE = gensym("LC_COLLATE"); +#endif +#if HAVE_DECL_LC_MONETARY + sp_LC_MONETARY = gensym("LC_MONETARY"); +#endif +#if HAVE_DECL_LC_MESSAGES + sp_LC_MESSAGES = gensym("LC_MESSAGES"); +#endif +#if HAVE_DECL_LC_PAPER + sp_LC_PAPER = gensym("LC_PAPER"); +#endif +#if HAVE_DECL_LC_NAME + sp_LC_NAME = gensym("LC_NAME"); +#endif +#if HAVE_DECL_LC_ADDRESS + sp_LC_ADDRESS = gensym("LC_ADDRESS"); +#endif +#if HAVE_DECL_LC_TELEPHONE + sp_LC_TELEPHONE = gensym("LC_TELEPHONE"); +#endif +#if HAVE_DECL_LC_MEASUREMENT + sp_LC_MEASUREMENT = gensym("LC_MEASUREMENT"); +#endif +#if HAVE_DECL_LC_IDENTIFICATION + sp_LC_IDENTIFICATION = gensym("LC_IDENTIFICATION"); +#endif +} + +/*-------------------------------------------------------------------- + * setup + */ +void locale_setup(void) +{ + post(locale_banner); +#ifdef LOCALE_DEBUG + post("locale : debugging enabled"); +#endif + + //-- constants + locale_setup_constants(); + + //-- class + locale_class = class_new(gensym("locale"), + (t_newmethod)locale_new, + (t_method)locale_free, + sizeof(t_locale), + CLASS_DEFAULT, + 0); + + //-- methods: get + class_addmethod(locale_class, (t_method)locale_get, gensym("get"), A_DEFSYMBOL, 0); + class_addmethod(locale_class, (t_method)locale_which, gensym("which"), 0); + // + //-- methods: set + class_addmethod(locale_class, (t_method)locale_set, gensym("set"), A_DEFSYMBOL, A_DEFSYMBOL, 0); + class_addmethod(locale_class, (t_method)locale_bang, &s_bang, 0); + class_addmethod(locale_class, (t_method)locale_reset, gensym("reset"), 0); + + + //-- help symbol + class_sethelpsymbol(locale_class, gensym("locale-help.pd")); +} -- cgit v1.2.1