return 0;
}
-// converts libreoffice csv to string (with quotes attached)
+// converts libreoffice csv stuttered quoted string (with quotes attached)
// quote marks only
static void xlat1(uint8_t *&in, uint8_t *out)
{
uint8_t *ibp = in, *obp = out;
- unsigned ch;
+ unsigned ch, lch = 0;
if( (ch=wnext(in)) == '\"' ) {
bool is_nested = in[0] == '\"' && in[1] == '\"';
while( (ch=wnext(in)) != 0 ) {
- if( ch == '\"' ) {
+ if( ch == '\"' && lch != '\\' ) {
uint8_t *bp = in;
unsigned nch = wnext(in);
if( nch != '\"' ) { in = bp; break; }
}
- wnext(out, ch);
+ wnext(out, lch = ch);
}
if( is_nested && ch == '"' ) {
while( out > obp && *(out-1) == ' ' ) --out;
// converts string (with opn/cls attached) to c string
static void xlat2(uint8_t *in, uint8_t *out)
{
- uint8_t *obp = out;
- unsigned lch = 0, ch = gch(in);
- if( ch ) {
- if( !is_opnr(ch) ) wnext(out, ch);
+ unsigned lch = gch(in), sep = 0, rch = 0, ch;
+ if( lch ) {
+ if( is_opnr(lch) ) {
+ for( uint8_t *ip=in; (ch=gch(ip))!=0; rch=ch );
+ if( lch == rch ) { sep = lch; lch = gch(in); }
+ }
while( (ch=gch(in)) != 0 ) {
- lch = ch; obp = out;
- wnext(out, ch);
+ wnext(out, lch); lch = ch;
}
- if( lch && is_opnr(lch) ) out = obp;
+ if( !sep ) wnext(out, lch);
}
*out = 0;
}
+int brkput = 0;
+
// converts c++ string to c string text
static void xlat3(const char *cp, uint8_t *out)
{
}
wnext(out,'\\');
wnext(out, ch);
- if( ch == 'n' && *bp ) {
+ if( brkput && ch == 'n' && *bp ) {
wnext(out, '\"');
wnext(out, '\n');
wnext(out, '\"');
case '\r': ch = 'r'; break;
case '\t': ch = 't'; break;
case '\v': ch = 'v'; break;
- case '\"': wnext(out,ch); // fall thru
+ case '\"': break;
default: wnext(out,ch); continue;
}
wnext(out,'\\');
bch = bp >= bep ? 0 : wnext(bp);
}
if( !ach || !bch ) break;
+ if( !*ap && !*bp ) break;
// if % on a and % on b and is fmt_spec
if( is_per(ach) && is_per(bch) && (n=fmt_spec(ap)) > 0 ) {
if( apr && apr != bpr ) wnext(cp,apr);
if( it == trans.end() || it->first.compare(key) ) {
fprintf(stderr, "no trans line %d: %s\n", no, ibfr);
xlat3(key.c_str(), &tbfr[7]);
- no += bputs(tbfr, ofp);
- no += bputs((uint8_t*)"#msgstr \"\"", ofp);
+ //no += bputs(tbfr, ofp);
+ no += bputs((uint8_t*)"msgstr \"\"", ofp);
}
- else if( !it->second.ok ) {
+ else if( 0 && !it->second.ok ) {
fprintf(stderr, "bad fmt line %d: %s\n", no, ibfr);
xlat3(it->first.c_str(), &tbfr[7]);
no += bputs(tbfr, ofp);
return 1;
}
+ brkput = 1;
for( int i=3; i<ac; ++i ) { // create trans mapping
fprintf(stderr,"*** load %s\n", av[i]);
char fn[MX_STR*2];