• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/support/kconfig/kxgettext.c
Thomas PetazzoniThomas Petazzoni committed 6997e461fdb04 Apr 2013
Raw file
Source viewDiff to previous
static int message__add_file_line(struct message *self, const char *file,
 
1
/*
2
 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 2005
3
 *
4
 * Released under the terms of the GNU GPL v2.0
5
 */
6
​
7
#include <stdlib.h>
8
#include <string.h>
9
​
10
#include "lkc.h"
11
​
12
static char *escape(const char* text, char *bf, int len)
13
{
14
    char *bfp = bf;
15
    int multiline = strchr(text, '\n') != NULL;
16
    int eol = 0;
17
    int textlen = strlen(text);
18
​
19
    if ((textlen > 0) && (text[textlen-1] == '\n'))
20
        eol = 1;
21
​
22
    *bfp++ = '"';
23
    --len;
24
​
25
    if (multiline) {
26
        *bfp++ = '"';
27
        *bfp++ = '\n';
28
        *bfp++ = '"';
29
        len -= 3;
30
    }
31
​
32
    while (*text != '\0' && len > 1) {
33
        if (*text == '"')
34
            *bfp++ = '\\';
35
        else if (*text == '\n') {
36
            *bfp++ = '\\';
37
            *bfp++ = 'n';
38
            *bfp++ = '"';
39
            *bfp++ = '\n';
40
            *bfp++ = '"';
41
            len -= 5;
42
            ++text;
43
            goto next;
44
        }
45
        else if (*text == '\\') {
46
            *bfp++ = '\\';
47
            len--;
48
        }
49
        *bfp++ = *text++;
50
next:
51
        --len;
52
    }
53
​
54
    if (multiline && eol)
55
        bfp -= 3;
56
​
57
    *bfp++ = '"';
58
    *bfp = '\0';
59
​
60
    return bf;
61
}
62
​
63
struct file_line {
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.