Fix bug #18339 with segfault when $ is typed into empty LaTeX buffer.
Back-ported from trunk revision-id: eliz@gnu.org-20140827194054-k7hd0vvmleql9wos

 src/syntax.c (scan_lists): Don't examine positions before BEGV.
* lisp/tar-mode.el (tar--extract, tar-extract): Avoid disabling undo
in extracted buffers.
* lisp/startup.el (fancy-splash-frame): Extend the fix for Bug#16014 to the Cygwin-w32 build.  (Bug#18347)
Minor ChangeLog fix.
* src/conf_post.h (strnicmp) [CYGWIN && HAVE_NTGUI]: Define.  (Bug#18366)
Fix cursor drawing in hscrolled R2L screen lines.

 src/xdisp.c (get_glyph_string_clip_rects): Don't let the width of a
 clipping rectangle become negative (i.e. large positive, since
 it's an unsigned data type).  This can happen in R2L hscrolled
 glyph rows, and caused us to draw the cursor glyph on the fringe.
 For the details, see
 http://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00543.html.
Fix cursor display on the fringe of R2L screen lines.

 src/xdisp.c (display_and_set_cursor): Call erase_phys_cursor also
 when HPOS is negative, for the benefit of R2L glyph rows whose
 newline overflows into the fringe.
Replace mode-specific quit function in ibuffer.el

* lisp/ibuffer.el: Replace mode-specific quit function with
`quit-window' via `special-mode'.
(ibuffer-mode-map): Use keybindings from special-mode-map instead
of local overrides.
(ibuffer): Don't store previous windows configuration. Let
`quit-window' handle restoring.
(ibuffer-quit): Remove function. Use `quit-window' instead.
(ibuffer-restore-window-config-on-quit): Remove variable.
(ibuffer-prev-window-config): Remove variable.
* etags.c (emacs_strchr, emacs_strrchr): Remove.

All uses replaced by strchr and strrchr, which are on all
target platforms now.
Clean up extern decls a bit.

* configure.ac (WERROR_CFLAGS): Don't disable -Wnested-externs.
While we're at it, don't disable -Wlogical-op either.
* src/bytecode.c: Include blockinput.h and keyboard.h rather
than rolling their APIs by hand.
* src/emacs.c: Include regex.h and rely on its and lisp.h's API
rather than rolling them by hand.
* src/lastfile.c: Include lisp.h, to check this file's API.
* src/lisp.h (lisp_eval_depth, my_edata, my_endbss, my_endbss_static):
New decls.
* src/regex.h (re_max_failures): New decl.
* src/unexcw.c, src/unexmacosx.c, src/unexw32.c:
Rely on lisp.h's API rather than rolling it by hand.
* src/vm-limit.c (__after_morecore_hook, __morecore, real_morecore):
Declare at top level, to pacify GCC -Wnested-externs.
--enable-silent-warnings now suppresses more chatter.

* INSTALL, etc/NEWS: Document this.
* lib-src/Makefile.in (AM_DEFAULT_VERBOSITY, AM_V_CC, am__v_CC_)
(am__v_CC_0, am__v_CC_1, AM_V_CCLD, am__v_CCLD_, am__v_CCLD_0)
(am__v_CCLD_1): New macros, taken from Automake.
(regex.o, etags${EXEEXT}, ctags${EXEEXT}, ebrowse${EXEEXT})
(profile${EXEEXT}, make-docfile${EXEEXT}, movemail${EXEEXT})
(pop.o, emacsclient${EXEEXT}, emacsclientw${EXEEXT})
(emacsclientw${EXEEXT}, ntlib.o, hexl${EXEEXT})
(update-game-score${EXEEXT}): Use them.
* lwlib/Makefile.in (AM_DEFAULT_VERBOSITY, AM_V_CC, am__v_CC_)
(am__v_CC_0, am__v_CC_1): New macros, taken from Automake.
(.c.o): Use them.
* oldXMenu/Makefile.in (AM_DEFAULT_VERBOSITY, AM_V_CC, am__v_CC_)
(am__v_CC_0, am__v_CC_1): New macros, taken from Automake.
(.c.o): Use them.
* src/Makefile.in (AM_DEFAULT_VERBOSITY, AM_V_CC, am__v_CC_)
(am__v_CC_0, am__v_CC_1, AM_V_CCLD, am__v_CCLD_, am__v_CCLD_0)
(am__v_CCLD_1): New macros, taken from Automake.
(.c.o, .m.o, temacs$(EXEEXT)): Use them.
Fix typo in previous change's ChangeLog.
Auto-commit of loaddefs files.
src/lastfile.c: Fix last change.
Use the new string-collate-lessp function in ls-lisp.el.

 lisp/ls-lisp.el (ls-lisp-use-string-collate)
 (ls-lisp-UCA-like-collation): New defcustoms.
 (ls-lisp-string-lessp): Use them to control sorting by file
 names.

 etc/NEWS: Mention that ls-lisp uses string-collate-lessp.
Implement the GNU ls -v switch in ls-lisp.el.

 lisp/ls-lisp.el (ls-lisp-version-lessp): New function.
 (ls-lisp-handle-switches): Use it to implement the -v switch of GNU ls.
 (ls-lisp--insert-directory): Mention the -v switch in the doc string.
src/w32proc.c (w32_compare_strings): Support "C" and "POSIX" locales.
nt/gnulib.mk: Synchronize with lib/gnulib.mk.
Avoid extra calls to strlen in filesystem I/O routines.
* fileio.c (Fexpand_file_name): Avoid calls to strlen if
the length of 'newdir' is known or may be precalculated.
(file_accessible_directory_p): Prefer to pass Lisp_Object,
not 'char *', and so use precalculated length.
(Ffile_accessible_directory_p):
* callproc.c (encode_current_directory, init_callproc):
* charset.c (init_charset):
* lread.c (load_path_check, load_path_default): Adjust users.
* lisp.h (file_accessible_directory_p): Tweak prototype.
* lisp/tutorial.el (tutorial--display-changes): Fix 2014-07-29 change.