-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcomment.c
47 lines (39 loc) · 966 Bytes
/
comment.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <string.h>
#include "c2ada.h"
comment_block_pt new_comment_block()
{
return (comment_block_pt)allocate(sizeof(struct comment_block));
}
void add_comment_line(comment_block_pt block, char* line)
{
comment_block_pt prev;
while(block && block->count == COMMENT_BLOCKSIZE)
{
prev = block;
block = block->next;
}
if(!block)
{
block = prev->next = new_comment_block();
}
block->line[block->count++] = line;
}
void put_comment_block(comment_block_pt block, int indent)
{
comment_block_pt cb;
char* str;
int i;
/* TBD: This routine might be the place to deallocate comment blocks. */
if(!block)
return;
for(cb = block; cb; cb = cb->next)
{
for(i = 0; i < cb->count; i++)
{
for(str = strtok(cb->line[i], "\n"); str; str = strtok(0, "\n"))
{
putf("%>%-- %s\n", indent, str);
}
}
}
}