diff options
| author | Junio C Hamano <junkio@cox.net> | 2006-10-25 13:29:12 -0700 | 
|---|---|---|
| committer | Junio C Hamano <junkio@cox.net> | 2006-10-25 13:29:12 -0700 | 
| commit | 9ee93dceb5dbef8052b0abde3eea94181bd9d95b (patch) | |
| tree | 2643405a0c9846b8985c95f9af8fd95f6bbcbc1e /quote.c | |
| parent | 8e95026f2942c2c485d9686736d861a6477480b5 (diff) | |
| parent | 1729fa9878ed8c99ae0bb2aecced557618d0c894 (diff) | |
| download | git-9ee93dceb5dbef8052b0abde3eea94181bd9d95b.tar.gz | |
Merge for-each-ref to sync gitweb fully with 'next'
Diffstat (limited to 'quote.c')
| -rw-r--r-- | quote.c | 38 | 
1 files changed, 38 insertions, 0 deletions
| @@ -349,3 +349,41 @@ void write_name_quoted(const char *prefix, int prefix_len,  	else  		goto no_quote;  } + +/* quoting as a string literal for other languages */ + +void perl_quote_print(FILE *stream, const char *src) +{ +	const char sq = '\''; +	const char bq = '\\'; +	char c; + +	fputc(sq, stream); +	while ((c = *src++)) { +		if (c == sq || c == bq) +			fputc(bq, stream); +		fputc(c, stream); +	} +	fputc(sq, stream); +} + +void python_quote_print(FILE *stream, const char *src) +{ +	const char sq = '\''; +	const char bq = '\\'; +	const char nl = '\n'; +	char c; + +	fputc(sq, stream); +	while ((c = *src++)) { +		if (c == nl) { +			fputc(bq, stream); +			fputc('n', stream); +			continue; +		} +		if (c == sq || c == bq) +			fputc(bq, stream); +		fputc(c, stream); +	} +	fputc(sq, stream); +} | 
