OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [intl/] [log.c] - Blame information for rev 866

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Log file output.
2
   Copyright (C) 2003 Free Software Foundation, Inc.
3
 
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
 
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
 
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
17
   USA.  */
18
 
19
/* Written by Bruno Haible <bruno@clisp.org>.  */
20
 
21
#ifdef HAVE_CONFIG_H
22
# include <config.h>
23
#endif
24
 
25
#include <stdio.h>
26
#include <stdlib.h>
27
#include <string.h>
28
 
29
/* Print an ASCII string with quotes and escape sequences where needed.  */
30
static void
31
print_escaped (stream, str)
32
     FILE *stream;
33
     const char *str;
34
{
35
  putc ('"', stream);
36
  for (; *str != '\0'; str++)
37
    if (*str == '\n')
38
      {
39
        fputs ("\\n\"", stream);
40
        if (str[1] == '\0')
41
          return;
42
        fputs ("\n\"", stream);
43
      }
44
    else
45
      {
46
        if (*str == '"' || *str == '\\')
47
          putc ('\\', stream);
48
        putc (*str, stream);
49
      }
50
  putc ('"', stream);
51
}
52
 
53
/* Add to the log file an entry denoting a failed translation.  */
54
void
55
_nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural)
56
     const char *logfilename;
57
     const char *domainname;
58
     const char *msgid1;
59
     const char *msgid2;
60
     int plural;
61
{
62
  static char *last_logfilename = NULL;
63
  static FILE *last_logfile = NULL;
64
  FILE *logfile;
65
 
66
  /* Can we reuse the last opened logfile?  */
67
  if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0)
68
    {
69
      /* Close the last used logfile.  */
70
      if (last_logfilename != NULL)
71
        {
72
          if (last_logfile != NULL)
73
            {
74
              fclose (last_logfile);
75
              last_logfile = NULL;
76
            }
77
          free (last_logfilename);
78
          last_logfilename = NULL;
79
        }
80
      /* Open the logfile.  */
81
      last_logfilename = (char *) malloc (strlen (logfilename) + 1);
82
      if (last_logfilename == NULL)
83
        return;
84
      strcpy (last_logfilename, logfilename);
85
      last_logfile = fopen (logfilename, "a");
86
      if (last_logfile == NULL)
87
        return;
88
    }
89
  logfile = last_logfile;
90
 
91
  fprintf (logfile, "domain ");
92
  print_escaped (logfile, domainname);
93
  fprintf (logfile, "\nmsgid ");
94
  print_escaped (logfile, msgid1);
95
  if (plural)
96
    {
97
      fprintf (logfile, "\nmsgid_plural ");
98
      print_escaped (logfile, msgid2);
99
      fprintf (logfile, "\nmsgstr[0] \"\"\n");
100
    }
101
  else
102
    fprintf (logfile, "\nmsgstr \"\"\n");
103
  putc ('\n', logfile);
104
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.