summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-02-23 05:23:53 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-02-23 05:23:53 +0000
commit25fea6be0a210199478da48dc7cb65a0f0f8a103 (patch)
treeea5626119f92e105063e033503e58e5a502b169e
parent736d10c2741397ca43ff9c41295a81be1d358d23 (diff)
added _mesa_find_line_column()
-rw-r--r--src/mesa/main/nvprogram.c37
-rw-r--r--src/mesa/main/nvprogram.h6
2 files changed, 41 insertions, 2 deletions
diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c
index b6960c0df8..207d705a18 100644
--- a/src/mesa/main/nvprogram.c
+++ b/src/mesa/main/nvprogram.c
@@ -1,4 +1,4 @@
-/* $Id: nvprogram.c,v 1.3 2003/02/16 23:07:36 brianp Exp $ */
+/* $Id: nvprogram.c,v 1.4 2003/02/23 05:23:53 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -141,6 +141,41 @@ _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string)
}
+const char *
+_mesa_find_line_column(const char *string, const char *pos,
+ GLint *line, GLint *col)
+{
+ const char *lineStart = string;
+ const char *p = string;
+ char *s;
+ int len;
+
+ *line = 1;
+
+ while (p != pos) {
+ if (*p == '\n') {
+ (*line)++;
+ lineStart = p + 1;
+ }
+ p++;
+ }
+
+ *col = (pos - lineStart) + 1;
+
+ /* return copy of this line */
+ while (*p != 0 && *p != '\n')
+ p++;
+ len = p - lineStart;
+ s = (char *) _mesa_malloc(len + 1);
+ _mesa_memcpy(s, lineStart, len);
+ s[len] = 0;
+
+ return s;
+}
+
+
+
+
/**
* Delete a program and remove it from the hash table, ignoring the
* reference count.
diff --git a/src/mesa/main/nvprogram.h b/src/mesa/main/nvprogram.h
index 5d31ebba3b..c58b0edf5d 100644
--- a/src/mesa/main/nvprogram.h
+++ b/src/mesa/main/nvprogram.h
@@ -1,4 +1,4 @@
-/* $Id: nvprogram.h,v 1.2 2003/02/16 23:07:36 brianp Exp $ */
+/* $Id: nvprogram.h,v 1.3 2003/02/23 05:23:54 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -55,6 +55,10 @@ _mesa_assign_program_registers(struct symbol_table *symbolTable);
extern void
_mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
+extern const char *
+_mesa_find_line_column(const char *string, const char *pos,
+ GLint *line, GLint *col);
+
extern void
_mesa_delete_program(GLcontext *ctx, GLuint id);