[pushed] gdb/python: exception trying to create empty array
Commit Message
> I think it might not be immediately obvious to the reader why the test
> is "n2 < n1 - 1".
> [E.g, there's no
> Can you add a comment?
Sure. Attached is the patch I just pushed.
gdb/ChangeLog:
* guile/scm-type.c (tyscm_array_1): Add comment.
* python/py-type.c (typy_array_1): Add comment.
From e810d75b1c9bef779b29df9d2c609fd5891d5917 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Wed, 7 Jan 2015 07:34:29 +0400
Subject: [PATCH] [python,guile] Add comment beside conditions testing empty
arrays.
gdb/ChangeLog:
* guile/scm-type.c (tyscm_array_1): Add comment.
* python/py-type.c (typy_array_1): Add comment.
---
gdb/ChangeLog | 5 +++++
gdb/guile/scm-type.c | 2 +-
gdb/python/py-type.c | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
@@ -1,3 +1,8 @@
+2015-01-07 Joel Brobecker <brobecker@adacore.com>
+
+ * guile/scm-type.c (tyscm_array_1): Add comment.
+ * python/py-type.c (typy_array_1): Add comment.
+
2015-01-06 Joel Brobecker <brobecker@adacore.com>
* guile/scm-type.c (tyscm_array_1): Do not raise out-of-range
@@ -713,7 +713,7 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector,
n1 = 0;
}
- if (n2 < n1 - 1)
+ if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */
{
gdbscm_out_of_range_error (func_name, SCM_ARG3,
scm_cons (scm_from_long (n1),
@@ -528,7 +528,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
n1 = 0;
}
- if (n2 < n1 - 1)
+ if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */
{
PyErr_SetString (PyExc_ValueError,
_("Array length must not be negative"));
--
1.9.1