mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-21 08:39:46 +08:00
8e98e3727d
dimensions). Added comprehensive tests that include variables with lots of combinations of 0 through 4 fixed and unlimited dimensions.
66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
/*********************************************************************
|
|
* Copyright 2007, UCAR/Unidata
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
* $Header: /upc/share/CVS/netcdf-3/ncdump/indent.c,v 1.6 2009/09/28 18:27:04 russ Exp $
|
|
*********************************************************************/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "indent.h"
|
|
static int indent = 0;
|
|
static int indent_increment = 2; /* blanks for each nesting level */
|
|
|
|
void
|
|
indent_init() { /* initialize output line indent */
|
|
indent = 0;
|
|
}
|
|
|
|
void
|
|
indent_out(){ /* output current indent */
|
|
/* Just does this, but we avoid looping for small indents:
|
|
|
|
int i;
|
|
for (i=0; i < indent; i++)
|
|
printf(" ");
|
|
|
|
*/
|
|
|
|
int indent_small = 8;
|
|
char* indents[] =
|
|
{"",
|
|
" ",
|
|
" ",
|
|
" ",
|
|
" ",
|
|
" ",
|
|
" ",
|
|
" ",
|
|
" "
|
|
};
|
|
|
|
int ind = indent;
|
|
while (ind > indent_small) {
|
|
(void) printf("%s", indents[indent_small]);
|
|
ind -= indent_small;
|
|
}
|
|
(void) printf("%s", indents[ind]);
|
|
}
|
|
|
|
void
|
|
indent_more(){ /* increment current indent */
|
|
indent += indent_increment;
|
|
}
|
|
|
|
void
|
|
indent_less(){ /* decrement current indent */
|
|
indent -= indent_increment;
|
|
if(indent < 0)
|
|
indent = 0;
|
|
}
|
|
|
|
int
|
|
indent_get() { /* return current indent */
|
|
return indent;
|
|
}
|
|
|