Use consistent indentation,
This commit is contained in:
parent
bbb8de0966
commit
397bd0938a
@ -74,72 +74,79 @@ int BIO_dump(BIO *bio, const char *s, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
|
int BIO_dump_indent(BIO *bio, const char *s, int len, int indent)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
char buf[288+1],tmp[20],str[128+1];
|
char buf[288+1],tmp[20],str[128+1];
|
||||||
int i,j,rows,trunc;
|
int i,j,rows,trunc;
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
int dump_width;
|
int dump_width;
|
||||||
|
|
||||||
trunc=0;
|
trunc=0;
|
||||||
|
|
||||||
#ifdef TRUNCATE
|
#ifdef TRUNCATE
|
||||||
for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--)
|
for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--)
|
||||||
trunc++;
|
trunc++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (indent < 0)
|
if (indent < 0)
|
||||||
indent = 0;
|
indent = 0;
|
||||||
if (indent) {
|
if (indent)
|
||||||
if (indent > 128) indent=128;
|
{
|
||||||
memset(str,' ',indent);
|
if (indent > 128) indent=128;
|
||||||
}
|
memset(str,' ',indent);
|
||||||
str[indent]='\0';
|
}
|
||||||
|
str[indent]='\0';
|
||||||
|
|
||||||
dump_width=DUMP_WIDTH_LESS_INDENT(indent);
|
dump_width=DUMP_WIDTH_LESS_INDENT(indent);
|
||||||
rows=(len/dump_width);
|
rows=(len/dump_width);
|
||||||
if ((rows*dump_width)<len)
|
if ((rows*dump_width)<len)
|
||||||
rows++;
|
rows++;
|
||||||
for(i=0;i<rows;i++) {
|
for(i=0;i<rows;i++)
|
||||||
buf[0]='\0'; /* start with empty string */
|
{
|
||||||
strcpy(buf,str);
|
buf[0]='\0'; /* start with empty string */
|
||||||
sprintf(tmp,"%04x - ",i*dump_width);
|
strcpy(buf,str);
|
||||||
strcat(buf,tmp);
|
sprintf(tmp,"%04x - ",i*dump_width);
|
||||||
for(j=0;j<dump_width;j++) {
|
strcat(buf,tmp);
|
||||||
if (((i*dump_width)+j)>=len) {
|
for(j=0;j<dump_width;j++)
|
||||||
strcat(buf," ");
|
{
|
||||||
} else {
|
if (((i*dump_width)+j)>=len)
|
||||||
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
{
|
||||||
sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
|
strcat(buf," ");
|
||||||
strcat(buf,tmp);
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
strcat(buf," ");
|
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
||||||
for(j=0;j<dump_width;j++) {
|
sprintf(tmp,"%02x%c",ch,j==7?'-':' ');
|
||||||
if (((i*dump_width)+j)>=len)
|
strcat(buf,tmp);
|
||||||
break;
|
}
|
||||||
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
}
|
||||||
|
strcat(buf," ");
|
||||||
|
for(j=0;j<dump_width;j++)
|
||||||
|
{
|
||||||
|
if (((i*dump_width)+j)>=len)
|
||||||
|
break;
|
||||||
|
ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
|
||||||
#ifndef CHARSET_EBCDIC
|
#ifndef CHARSET_EBCDIC
|
||||||
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
|
sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.');
|
||||||
#else
|
#else
|
||||||
sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
|
sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
|
||||||
? os_toebcdic[ch]
|
? os_toebcdic[ch]
|
||||||
: '.');
|
: '.');
|
||||||
#endif
|
#endif
|
||||||
strcat(buf,tmp);
|
strcat(buf,tmp);
|
||||||
}
|
}
|
||||||
strcat(buf,"\n");
|
strcat(buf,"\n");
|
||||||
/* if this is the last call then update the ddt_dump thing so that
|
/* if this is the last call then update the ddt_dump thing so that
|
||||||
* we will move the selection point in the debug window
|
* we will move the selection point in the debug window
|
||||||
*/
|
*/
|
||||||
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
||||||
}
|
}
|
||||||
#ifdef TRUNCATE
|
#ifdef TRUNCATE
|
||||||
if (trunc > 0) {
|
if (trunc > 0)
|
||||||
sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc);
|
{
|
||||||
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
sprintf(buf,"%s%04x - <SPACES/NULS>\n",str,len+trunc);
|
||||||
}
|
ret+=BIO_write(bio,(char *)buf,strlen(buf));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user