Skip to content

Commit

Permalink
Avoid C99 comments, use old-style C comments instead.
Browse files Browse the repository at this point in the history
This doesn't make the code uglier or harder to read, yet it makes the
code more portable.  This also simplifies checking for other potential
incompatibilities.  "gcc -std=c89 -pedantic" can flag many incompatible
constructs as warnings, but C99 comments will cause it to emit an error.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Pavel Roskin authored and Junio C Hamano committed Jul 10, 2006
1 parent 82e5a82 commit a9486b0
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 31 deletions.
6 changes: 3 additions & 3 deletions blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ struct util_info {
};

struct chunk {
int off1, len1; // ---
int off2, len2; // +++
int off1, len1; /* --- */
int off2, len2; /* +++ */
};

struct patch {
Expand Down Expand Up @@ -255,7 +255,7 @@ static void print_map(struct commit *cmit, struct commit *other)
}
#endif

// p is a patch from commit to other.
/* p is a patch from commit to other. */
static void fill_line_map(struct commit *commit, struct commit *other,
struct patch *p)
{
Expand Down
21 changes: 11 additions & 10 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
#include "delta.h"
#include "builtin.h"

// --check turns on checking that the working tree matches the
// files that are being modified, but doesn't apply the patch
// --stat does just a diffstat, and doesn't actually apply
// --numstat does numeric diffstat, and doesn't actually apply
// --index-info shows the old and new index info for paths if available.
// --index updates the cache as well.
// --cached updates only the cache without ever touching the working tree.
//
/*
* --check turns on checking that the working tree matches the
* files that are being modified, but doesn't apply the patch
* --stat does just a diffstat, and doesn't actually apply
* --numstat does numeric diffstat, and doesn't actually apply
* --index-info shows the old and new index info for paths if available.
* --index updates the cache as well.
* --cached updates only the cache without ever touching the working tree.
*/
static const char *prefix;
static int prefix_length = -1;
static int newfd = -1;
Expand Down Expand Up @@ -284,8 +285,8 @@ static void parse_traditional_patch(const char *first, const char *second, struc
{
char *name;

first += 4; // skip "--- "
second += 4; // skip "+++ "
first += 4; /* skip "--- " */
second += 4; /* skip "+++ " */
if (is_dev_null(first)) {
patch->is_new = 1;
patch->is_delete = 0;
Expand Down
2 changes: 1 addition & 1 deletion builtin-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static int do_push(const char *repo)
int cmd_push(int argc, const char **argv, char **envp)
{
int i;
const char *repo = "origin"; // default repository
const char *repo = "origin"; /* default repository */

for (i = 1; i < argc; i++) {
const char *arg = argv[i];
Expand Down
12 changes: 6 additions & 6 deletions convert-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,27 @@ static void convert_date(void *buffer, unsigned long size, unsigned char *result
{
char *new = xmalloc(size + 100);
unsigned long newlen = 0;
// "tree <sha1>\n"

/* "tree <sha1>\n" */
memcpy(new + newlen, buffer, 46);
newlen += 46;
buffer = (char *) buffer + 46;
size -= 46;

// "parent <sha1>\n"
/* "parent <sha1>\n" */
while (!memcmp(buffer, "parent ", 7)) {
memcpy(new + newlen, buffer, 48);
newlen += 48;
buffer = (char *) buffer + 48;
size -= 48;
}

// "author xyz <xyz> date"
/* "author xyz <xyz> date" */
newlen += convert_date_line(new + newlen, &buffer, &size);
// "committer xyz <xyz> date"
/* "committer xyz <xyz> date" */
newlen += convert_date_line(new + newlen, &buffer, &size);

// Rest
/* Rest */
memcpy(new + newlen, buffer, size);
newlen += size;

Expand Down
2 changes: 1 addition & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
if (dir->show_other_directories &&
(subdir || !dir->hide_empty_directories) &&
!dir_exists(fullname, baselen + len)) {
// Rewind the read subdirectory
/* Rewind the read subdirectory */
while (dir->nr > rewind_base)
free(dir->entries[--dir->nr]);
break;
Expand Down
6 changes: 3 additions & 3 deletions http-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static int setup_index(struct alt_base *repo, unsigned char *sha1)
{
struct packed_git *new_pack;
if (has_pack_file(sha1))
return 0; // don't list this as something we can get
return 0; /* don't list this as something we can get */

if (fetch_index(repo, sha1))
return -1;
Expand Down Expand Up @@ -570,7 +570,7 @@ static void process_alternates_response(void *callback_data)
base[serverlen - 1] != '/');
i += 3;
}
// If the server got removed, give up.
/* If the server got removed, give up. */
okay = strchr(base, ':') - base + 3 <
serverlen;
} else if (alt_req->http_specific) {
Expand All @@ -581,7 +581,7 @@ static void process_alternates_response(void *callback_data)
okay = 1;
}
}
// skip 'objects' at end
/* skip 'objects' at end */
if (okay) {
target = xmalloc(serverlen + posn - i - 6);
strlcpy(target, base, serverlen);
Expand Down
5 changes: 3 additions & 2 deletions mktag.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* in that size, you're doing something wrong.
*/

// Some random size
/* Some random size */
#define MAXSIZE (8192)

/*
Expand Down Expand Up @@ -123,7 +123,8 @@ int main(int argc, char **argv)
die("could not read from stdin");
}

// Verify it for some basic sanity: it needs to start with "object <sha1>\ntype\ntagger "
/* Verify it for some basic sanity: it needs to start with
"object <sha1>\ntype\ntagger " */
if (verify_tag(buffer, size) < 0)
die("invalid tag signature file");

Expand Down
2 changes: 1 addition & 1 deletion read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ int read_cache(void)
die("index file open failed (%s)", strerror(errno));
}

size = 0; // avoid gcc warning
size = 0; /* avoid gcc warning */
map = MAP_FAILED;
if (!fstat(fd, &st)) {
size = st.st_size;
Expand Down
4 changes: 2 additions & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ int use_packed_git(struct packed_git *p)
{
if (!p->pack_size) {
struct stat st;
// We created the struct before we had the pack
/* We created the struct before we had the pack */
stat(p->pack_name, &st);
if (!S_ISREG(st.st_mode))
die("packfile %s not a regular file", p->pack_name);
Expand Down Expand Up @@ -1504,7 +1504,7 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize)
int hdrlen;
void *buf;

// need to unpack and recompress it by itself
/* need to unpack and recompress it by itself */
unpacked = read_packed_sha1(sha1, type, &len);

hdrlen = sprintf(hdr, "%s %lu", type, len) + 1;
Expand Down
4 changes: 2 additions & 2 deletions ssh-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int fetch(unsigned char *sha1)
struct object_list *temp;

if (memcmp(sha1, in_transit->item->sha1, 20)) {
// we must have already fetched it to clean the queue
/* we must have already fetched it to clean the queue */
return has_sha1_file(sha1) ? 0 : -1;
}
prefetches--;
Expand All @@ -85,7 +85,7 @@ int fetch(unsigned char *sha1)
if (read(fd_in, &remote, 1) < 1)
return -1;
}
//fprintf(stderr, "Got %d\n", remote);
/* fprintf(stderr, "Got %d\n", remote); */
if (remote < 0)
return remote;
ret = write_sha1_from_fd(sha1, fd_in, conn_buf, 4096, &conn_buf_posn);
Expand Down

0 comments on commit a9486b0

Please sign in to comment.