Index: /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp
===================================================================
--- /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp	(revision 10626)
+++ /issm/trunk/src/c/objects/KML/KMLFileReadUtils.cpp	(revision 10627)
@@ -23,13 +23,15 @@
 char* KMLFileToken(FILE* fid){
 
+/*  get the next token (tag or field) in the file  */
+
 	bool    inew=1,itag=0,ifield=0;
 	int     c;
 	int     ibuf=0,buflen=1024,bufblk=1024;
-	char*   buffer=NULL;
+	char    *buffer=NULL,*bufferc=NULL;
 
 	buffer=(char *) xmalloc(buflen*sizeof(char));
 	buffer[0]='\0';
 
-/*  read kml file  */
+/*  read kml file character-by-character  */
 
 //  note that fgets includes newline
@@ -38,4 +40,5 @@
 	while ((c=getc(fid)) != EOF) {
 		/*  ignore leading blanks  */
+//		printf("point 0 c=%c\n",c);
 		if (inew && isspace(c))
 			continue;
@@ -43,6 +46,21 @@
 		/*  distinguish between tag or field  */
 		if (!itag && !ifield) {
-			if (c == '<')
-				itag=1;
+
+			/*  distinguish between tag or comment  */
+			if (c == '<') {
+//				printf("point 1 c=%c\n",c);
+				ungetc(c,fid);
+				if (!(bufferc=KMLFileTokenComment(fid))) {
+					c=getc(fid);
+//					printf("point 2 c=%c\n",c);
+					itag=1;
+				}
+				else {
+//					printf("point 3 buffer=%s\n",buffer);
+					xfree((void**)&bufferc);
+					inew=1;
+					continue;
+				}
+			}
 			else
 				ifield=1;
@@ -69,7 +87,11 @@
 		/*  accumulate field, including newlines  */
 		else if (ifield) {
+			/*  distinguish between closing tag or comment  */
 			if (c == '<') {
 				ungetc(c,fid);
-				break;
+				if (!(bufferc=KMLFileTokenComment(fid)))
+					break;
+				else
+					xfree((void**)&bufferc);
 			}
 			else {
@@ -95,9 +117,77 @@
 		}
 
-//	if      (itag)
-//		_printf_(true,"tag buffer (length=%d):\n",ibuf);
-//	else if (ifield)
-//		_printf_(true,"field buffer (length=%d):\n",ibuf);
-//	_printf_(true,"%s\n",buffer);
+	if      (itag)
+		_printf_(true,"tag buffer (length=%d):\n",ibuf);
+	else if (ifield)
+		_printf_(true,"field buffer (length=%d):\n",ibuf);
+	_printf_(true,"%s\n",buffer);
+
+	if (!ibuf)
+		xfree((void**)&buffer);
+
+	return(buffer);
+}
+/*}}}*/
+
+/*FUNCTION  KMLFileTokenComment(FILE* fid) {{{1*/
+char* KMLFileTokenComment(FILE* fid){
+
+/*  check for comment in the file and read it  */
+
+	bool    inew=1;
+	int     i;
+	int     c;
+	int     ibuf=0,buflen=1024,bufblk=1024;
+	char*   buffer=NULL;
+
+	buffer=(char *) xmalloc(buflen*sizeof(char));
+	buffer[0]='\0';
+
+/*  read kml file character-by-character  */
+
+	while ((c=getc(fid)) != EOF) {
+//		printf("point 10 c=%c\n",c);
+		/*  ignore leading blanks  */
+		if (inew && isspace(c))
+			continue;
+
+		inew=0;
+		KMLFileTokenBuffer(&buffer,&ibuf,&buflen,
+						   c,
+						   bufblk);
+
+		/*  check for comment  */
+		if (ibuf <= 4) {
+			if ((ibuf == 1 && buffer[0] != '<') ||
+				(ibuf == 2 && buffer[1] != '!') ||
+				(ibuf == 3 && buffer[2] != '-') ||
+				(ibuf == 4 && buffer[3] != '-')) {
+				for (i=ibuf-1; i>=0; i--)
+					ungetc(buffer[i],fid);
+//				printf("point 11 buffer=%p\n",buffer);
+				xfree((void**)&buffer);
+//				printf("point 12 buffer=%p\n",buffer);
+				return(buffer);
+			}
+		}
+
+		/*  accumulate comment, including newlines  */
+		else
+			if (buffer[ibuf-3]=='-' && buffer[ibuf-2]=='-' && buffer[ibuf-1]=='>')
+				break;
+	}
+
+/*  remove trailing blanks or newline  */
+
+	while (ibuf > 0)
+		if (isspace(buffer[ibuf-1]))
+			ibuf--;
+		else {
+			buffer[ibuf]='\0';
+			break;
+		}
+
+	_printf_(true,"comment buffer (length=%d):\n",ibuf);
+	_printf_(true,"%s\n",buffer);
 
 	if (!ibuf)
@@ -113,4 +203,6 @@
 						int bufblk){
 
+/*  add the specified character to the token buffer  */
+
 	char*   buffer=NULL;
 
@@ -134,4 +226,6 @@
 void KMLFileTagAttrib(KML_Object* kobj,
 					  char* ktag){
+
+/*  for the given tag buffer, read and store the attributes  */
 
 	char*   ktagi;
@@ -144,5 +238,4 @@
 	ktagi=(char *) xmalloc((strlen(ktag)+1)*sizeof(char));
 	memcpy(ktagi,ktag,(strlen(ktag)+1)*sizeof(char));
-
 
 /*  loop through tag to find all attributes  */
Index: /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h
===================================================================
--- /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h	(revision 10626)
+++ /issm/trunk/src/c/objects/KML/KMLFileReadUtils.h	(revision 10627)
@@ -16,4 +16,5 @@
 /* local prototypes: */
 char* KMLFileToken(FILE* fid);
+char* KMLFileTokenComment(FILE* fid);
 void KMLFileTokenBuffer(char** pbuffer,int* pibuf,int* pbuflen,
 						int c,
