Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

_cupsStrFormatd() doesn't format decimal values properly #2296

Closed

Description

@michaelrsweet

Version: 1.2-current
CUPS.org User: mike

The _cupsStrFormatd() function (which is used for formatting locale-independent decimal numbers in PS output, among other places) incorrectly formats decimal numbers (you get double decimal points...)

Activity

  1. michaelrsweet commented on Mar 17, 2007

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

  2. michaelrsweet commented on Mar 17, 2007

    @michaelrsweet
    ContributorAuthor

    "str2296.patch":

    Index: string.c

    --- string.c (revision 6342)
    +++ string.c (working copy)
    @@ -266,9 +266,9 @@
    tempptr < tempdec && bufptr < bufend;
    *bufptr++ = *tempptr++);

    • tempdec += declen;
    • tempptr += declen;
    • if (*tempdec && bufptr < bufend)
    • if (*tempptr && bufptr < bufend)
      {
      *bufptr++ = '.';

    Index: testlang.c

    --- testlang.c (revision 6342)
    +++ testlang.c (working copy)
    @@ -34,6 +34,7 @@

    #include <stdio.h>
    #include "i18n.h"
    +#include "string.h"

    /*
    @@ -44,10 +45,24 @@
    main(int argc, /* I - Number of command-line arguments /
    char *argv[]) /
    I - Command-line arguments */
    {

    • int i; /* Looping var */
    • int errors = 0; /* Number of errors /
      cups_lang_t *language; /
      Message catalog /
      cups_lang_t *language2; /
      Message catalog */
    • struct lconv loc; / Locale data */
    • char buffer[1024]; /* String buffer */
    • double number; /* Number */
    • static const char * const tests[] = /* Test strings */
    • {
    • "1",
    • "-1",
    • "3",
    • "5.125"
    • };
    • _cupsSetLocale(argv);

    if (argc == 1)
    {
    language = cupsLangDefault();
    @@ -61,6 +76,8 @@

    if (language != language2)
    {

    • errors ++;

    puts("**** ERROR: Language cache did not work! ****");
    puts("First result from cupsLangGet:");
    }
    @@ -80,7 +97,26 @@
    printf("Yes = "%s"\n", _cupsLangString(language2, "Yes"));
    }

    • return (0);
    • loc = localeconv();
    • for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++)
    • {
    • number = _cupsStrScand(tests[i], NULL, loc);
    • printf("_cupsStrScand("%s") number=%f\n", tests[i], number);
    • _cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc);
    • printf("_cupsStrFormatd(%f) buffer="%s"\n", number, buffer);
    • if (strcmp(buffer, tests[i]))
    • {
    •  errors ++;
      
    •  puts("***\* ERROR: Bad formatted number! ****");
      
    • }
    • }
    • return (errors > 0);
      }
  3. added this to the Stable milestone on Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions