incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: rewrite of 22.locale.ctype test (1st pass)
Date Wed, 09 May 2007 20:33:36 GMT
Scott Zhong wrote:
> There is a seg fault bug in 22.locale.ctype.narrow.cpp, other than that
> all the other test passes.

Cool! Unfortunately, Google seems to mangle the source code
(the names of #included headers are missing, for example),
so unless you can figure out how to make it display them
without change you'll need to post them somewhere else. I
haven't used Google Docs like this so I'm afraid I can't
suggest what to tweak.

Martin

> 
> 22.locale.ctype.is
> http://docs.google.com/Doc?id=dfxv3txk_0gbdtxf
> 
> 22.locale.ctype.narrow
> http://docs.google.com/Doc?id=dfxv3txk_1f3ns8m
> 
> 22.locale.ctype.scan
> http://docs.google.com/Doc?id=dfxv3txk_2fvj44m
> 
> 22.locale.ctype.tolower
> http://docs.google.com/Doc?id=dfxv3txk_3rs7tmx
> 
> 22.locale.ctype.toupper
> http://docs.google.com/Doc?id=dfxv3txk_4gc52v2
> 
> 12:23:pyramid2:/build/scottz/stdcxx/tests/include>>> svn diff
> rw_locale.h
> Index: rw_locale.h
> ===================================================================
> --- rw_locale.h (revision 534617)
> +++ rw_locale.h (working copy)
> @@ -2,7 +2,7 @@
>   *
>   * localedef.h - declarations of locale testsuite helpers
>   *
> - * $Id:$
> + * $Id$
>   *
>  
> ************************************************************************
>   *
> @@ -63,5 +63,13 @@
>  _TEST_EXPORT const char*
>  rw_localedef (const char*, const char*, const char*, const char*);
>  
> +// invokes localedef with charmap and locale def to create a locale
> database 
> +// in a directory specified by the RWSTD_LOCALE_ROOT environment
> +// variable, if it is defined, otherwise in the current working
> +// directory
> +// returns the name of the locale
> +_TEST_EXPORT const char*
> +rw_create_locale (const char *charmap, const char *locale);
>  
> +
>  #endif   // RW_LOCALE_H_INCLUDED
> 
> 12:22:pyramid2:/build/scottz/stdcxx/tests/src>>> svn diff locale.cpp
> Index: locale.cpp
> ===================================================================
> --- locale.cpp  (revision 534617)
> +++ locale.cpp  (working copy)
> @@ -35,6 +35,7 @@
>  #include <environ.h>      // for rw_putenv()
>  #include <file.h>         // for SHELL_RM_RF, rw_tmpnam
>  #include <rw_process.h>   // for rw_system()
> +#include <cstdio>
>  
>  
>  #if defined __linux__
> @@ -470,3 +471,63 @@
>  
>      return slocname;
>  }
> +
> +/**********************************************************************
> ****/
> +
> +const char*
> +rw_create_locale (const char *charmap, const char *locale)
> +{
> +    // only one locale is enough (avoid invoking localedef more than
> once)
> +    static const char* locname;
> +    const char* locale_root;
> +
> +    if (locname)
> +        return locname;
> +
> +    // set up RWSTD_LOCALE_ROOT and other environment variables
> +    locale_root = rw_set_locale_root ();
> +
> +    if (0 == locale_root)
> +        return 0;
> +
> +    // create a temporary locale definition file that exercises as
> +    // many different parts of the collate standard as possible
> +    char srcfname [256];
> +    std::sprintf (srcfname, "%s%slocale.src", locale_root, SLASH);
> +
> +    std::FILE *fout = std::fopen (srcfname, "w");
> +
> +    if (!fout) {
> +        std::fprintf (stderr, "%s:%d: fopen(\"%s\", \"w\") failed\n",
> +                      __FILE__, __LINE__, srcfname);
> +        return 0;
> +    }
> +
> +       std::fprintf (fout, "%s", locale);
> +
> +    std::fclose (fout);
> +
> +    // create a temporary character map file
> +    char cmfname [256];
> +    std::sprintf (cmfname, "%s%scharmap.src", locale_root, SLASH);
> +
> +    fout = std::fopen (cmfname, "w");
> +
> +    if (!fout) {
> +        std::fprintf (stderr, "%s:%d: fopen(\"%s\", \"w\") failed\n",
> +                      __FILE__, __LINE__, cmfname);
> +        return 0;
> +    }
> +
> +       std::fprintf (fout, "%s", charmap);
> +
> +    std::fclose (fout);
> +
> +       locname = "test-locale";
> +
> +    // process the locale definition file and character map
> +    if (0 == rw_localedef ("-w", srcfname, cmfname, locname))
> +        locname = 0;
> +
> +    return locname;
> +}
> 
> Yu (Scott) Zhong


Mime
View raw message