netsurf/Makefile.sources
John Mark Bell 23fb72ea6b The core code has always assumed a locale of "C".
Do not change the locale globally, else things will break in weird and 
wonderful ways.

Introduce utils/locale.[ch], which provide locale-specific wrappers for various 
functions (currently just the <ctype.h> ones).

Fix up the few places I can see that actually require that the underlying 
locale is paid attention to.

Some notes:

  1) The GTK frontend code has not been touched. It is possible that reading of 
     numeric values (e.g. from the preferences dialogue) may break with this 
     change, particularly in locales that use something other than '.' as their
     decimal separator.
  2) The search code is left unchanged (i.e. assuming a locale of "C"). 
     This may break case insensitive matching of non-ASCII characters. 
     I doubt that ever actually worked, anyway. In future, it should use
     Unicode case conversion to achieve the same effect.
  3) The text input handling in the core makes use of isspace() to detect
     word boundaries. This is fine for western languages (even in the C locale,
     which it's currently assuming). It will, however, break for CJK et. al. 
     (this has always been the case, rather than being a new issue)
  4) text-transform uses locale-specific variants of to{lower,upper}. In future
     this should probably be performing Unicode case conversion. This is the
     only part of the core code that makes use of locale information.

In future, if you require locale-specific behaviour, do the following:

  setlocale(LC_<whatever>, "");
  <your operation(s) here>
  setlocale(LC_<whatever>, "C");

  The first setlocale will change the current locale to the native environment.
  The second setlocale will reset the current locale to "C".
  Any value other than "" or "C" is probably a bug, unless there's a really
  good reason for it.

In the long term, it is expected that all locale-dependent code will reside in 
platform frontends -- the core being wholly locale agnostic (though assuming 
"C" for things like decimal separators).


svn path=/trunk/netsurf/; revision=4153
2008-05-13 14:37:44 +00:00

120 lines
4.1 KiB
Makefile

#
# Makefile for NetSurf
#
# Included by main makefile -- indicates sources
# for each build.
#
S_CONTENT := content.c fetch.c fetchcache.c urldb.c \
fetchers/fetch_curl.c fetchers/fetch_data.c
S_CSS := css.c css_enum.c parser.c ruleset.c scanner.c
S_RENDER := box.c box_construct.c box_normalise.c \
directory.c form.c html.c html_redraw.c \
imagemap.c layout.c list.c table.c textplain.c
S_UTILS := base64.c filename.c hashtable.c locale.c messages.c talloc.c \
url.c utf8.c utils.c useragent.c
S_DESKTOP := knockout.c options.c tree.c version.c
# S_COMMON are sources common to all builds
S_COMMON := $(addprefix content/,$(S_CONTENT)) \
$(addprefix css/,$(S_CSS)) \
$(addprefix render/,$(S_RENDER)) \
$(addprefix utils/,$(S_UTILS)) \
$(addprefix desktop/,$(S_DESKTOP))
S_IMAGE := bmp.c bmpread.c gif.c gifread.c ico.c jpeg.c \
mng.c nssprite.c svg.c rsvg.c
# S_IMAGE are sources related to image management
S_IMAGE := $(addprefix image/,$(S_IMAGE))
# S_BROWSER are sources related to full browsers but are common
# between RO and Unix builds
S_BROWSER := browser.c frames.c history_core.c netsurf.c save_text.c selection.c \
textinput.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
# S_RISCOS are sources purely for the RISC OS build
S_RISCOS := 401login.c artworks.c assert.c awrender.s bitmap.c buffer.c \
cookies.c configure.c debugwin.c dialog.c download.c draw.c filetype.c \
font.c global_history.c gui.c help.c history.c hotlist.c image.c \
menus.c message.c palettes.c plotters.c plugin.c print.c query.c \
save.c save_complete.c save_draw.c schedule.c search.c sprite.c \
sslcert.c textarea.c textselection.c theme.c theme_install.c \
thumbnail.c \
treeview.c ucstables.c uri.c url_complete.c url_protocol.c wimp.c wimp_event.c \
window.c gui/progress_bar.c gui/status_bar.c \
$(addprefix configure/,con_cache.c con_connect.c con_content.c con_fonts.c \
con_home.c con_image.c con_inter.c con_language.c con_memory.c con_secure.c \
con_theme.c)
S_RISCOS := $(addprefix riscos/,$(S_RISCOS))
# S_GTK are sources purely for the GTK build
S_GTK := font_pango.c gtk_bitmap.c gtk_gui.c gtk_schedule.c \
gtk_thumbnail.c gtk_options.c \
gtk_plotters.c gtk_treeview.c gtk_scaffolding.c gtk_completion.c \
gtk_login.c gtk_throbber.c \
gtk_history.c gtk_window.c gtk_filetype.c gtk_download.c
S_GTK := $(addprefix gtk/,$(S_GTK))
# Some extra rules for building the scanner etc.
css/css_enum.c css/css_enum.h: css/css_enums css/makeenum
$(VQ)echo "MAKEENUM: css"
$(Q)$(PERL) css/makeenum css/css_enum < css/css_enums
ifeq ($(HOST),riscos)
css/parser.c css/parser.h: css/parser.y
$(VQ)echo " LEMON: css/parser.y"
$(Q)dir css
$(Q)-lemon parser.y
$(Q)dir ^
$(Q)touch css/parser.c css/parser.h
css/scanner.c: css/scanner.l
$(VQ)echo " RE2C: css/scanner.l"
$(Q)dir css
$(Q)re2c -s scanner.l > scanner.c
$(Q)dir ^
utils/translit.c: transtab
$(VQ)echo "TRANSTAB: utils/translit.c"
$(Q)dir utils
$(Q)$(PERL) tt2code < transtab > translit.c
$(Q)dir ^
else
css/parser.c css/parser.h: css/parser.y
$(VQ)echo " LEMON: css/parser.y"
$(Q)# If lemon really fails hard, we'll never know, sorry
$(Q)cd css; lemon parser.y || true
$(Q)# Unfortunately if the output hasn't changed, lemon doesn't
$(Q)# alter the file and thus make gets confused.
$(Q)touch css/parser.c css/parser.h
css/scanner.c: css/scanner.l
$(VQ)echo " RE2C: css/scanner.l"
$(Q)cd css; re2c -s scanner.l > scanner.c
utils/translit.c: transtab
$(VQ)echo "TRANSTAB: utils/translit.c"
$(Q)cd utils; $(PERL) tt2code < transtab > translit.c
endif
clean-intermediates:
$(VQ)echo " CLEAN: intermediates"
$(Q)$(RM) css/css_enum.c css/css_enum.h css/parser.c css/parser.out css/parser.h
$(Q)$(RM) css/scanner.c utils/translit.c
CLEANS += clean-intermediates
# Finally select the correct set of sources for this build...
ifeq ($(TARGET),riscos)
SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_RISCOS)
EXETARGET := !NetSurf/!RunImage$(EXEEXT)
endif
ifeq ($(TARGET),gtk)
SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_GTK)
EXETARGET := nsgtk
endif
ifeq ($(SOURCES),)
$(error Unable to build NetSurf, could not determine set of sources to build)
endif