diff options
author | Bruno Haible <bruno@clisp.org> | 2012-07-01 18:07:20 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2012-07-01 18:07:20 +0200 |
commit | 064483191f4e0c443c6bff67b757eaa329602b2c (patch) | |
tree | d6913a06c2d8c93568d8d7463003fef613763c2a | |
parent | bf93ebd28ec4e6f92250ada2c17ac6e97b027ccb (diff) | |
download | gperf-064483191f4e0c443c6bff67b757eaa329602b2c.tar.gz |
Fix compilation error with MSVC.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/output.cc | 28 |
2 files changed, 34 insertions, 2 deletions
@@ -1,5 +1,13 @@ 2012-07-01 Bruno Haible <bruno@clisp.org> + Fix compilation error with MSVC. + * src/output.cc: Include config.h. + (DYNAMIC_ARRAY, FREE_DYNAMIC_ARRAY): New macros, copied from + src/search.cc. + (output_constant): Use them. + +2012-07-01 Bruno Haible <bruno@clisp.org> + Remove old infrastructure for building with MSVC. * autogen.sh: Don't remove src/config.h.msvc. * Makefile.devel (src/config.h.msvc): Remove rule. diff --git a/src/output.cc b/src/output.cc index d887233..9661ce0 100644 --- a/src/output.cc +++ b/src/output.cc @@ -1,5 +1,5 @@ /* Output routines. - Copyright (C) 1989-1998, 2000, 2002-2004, 2006-2007, 2009, 2011 Free Software Foundation, Inc. + Copyright (C) 1989-1998, 2000, 2002-2004, 2006-2007, 2009, 2011-2012 Free Software Foundation, Inc. Written by Douglas C. Schmidt <schmidt@ics.uci.edu> and Bruno Haible <bruno@clisp.org>. @@ -28,6 +28,29 @@ #include <limits.h> /* defines SCHAR_MAX etc. */ #include "options.h" #include "version.h" +#include "config.h" + +/* ============================== Portability ============================== */ + +/* Dynamically allocated array with dynamic extent: + + Example: + DYNAMIC_ARRAY (my_array, int, n); + ... + FREE_DYNAMIC_ARRAY (my_array); + + Attention: depending on your implementation my_array is either the array + itself or a pointer to the array! Always use my_array only as expression! + */ +#if HAVE_DYNAMIC_ARRAY + #define DYNAMIC_ARRAY(var,eltype,size) eltype var[size] + #define FREE_DYNAMIC_ARRAY(var) +#else + #define DYNAMIC_ARRAY(var,eltype,size) eltype *var = new eltype[size] + #define FREE_DYNAMIC_ARRAY(var) delete[] var +#endif + +/* ========================================================================= */ /* The "const " qualifier. */ static const char *const_always; @@ -220,10 +243,11 @@ static void output_constant (struct Output_Constants& style, const char *name, int value) { const char *prefix = option.get_constants_prefix (); - char combined_name[strlen (prefix) + strlen (name) + 1]; + DYNAMIC_ARRAY (combined_name, char, strlen (prefix) + strlen (name) + 1); strcpy (combined_name, prefix); strcpy (combined_name + strlen (prefix), name); style.output_item (combined_name, value); + FREE_DYNAMIC_ARRAY (combined_name); } /* Outputs the maximum and minimum hash values etc. */ |