David,
I see a number of these in the commit:
- char buf[n + 1];
+ char *buf = (char *)malloc(n + 1);
+ RexxObjectPtr tmp;
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
@@ -1634,7 +1638,9 @@
return 0;
}
mvwgetnstr((WINDOW *)cself, SUBTRACTONE(y), SUBTRACTONE(x), buf, n);
- return context->NewStringFromAsciiz(buf);
+ tmp = context->NewStringFromAsciiz(buf);
+ free(tmp);
+ return tmp;
Surely you mean:
tmp =
free(buf)
return tmp
I'm sure you would catch it quick enough, just thought I'd point it
out in case it causes some odd behavior that is hard to debug.
--
Mark Miesfeld
---------- Forwarded message ----------
From: <[email protected]>
Date: Sat, Jan 30, 2010 at 4:48 PM
Subject: [Oorexx-svn] SF.net SVN: oorexx:[5521] incubator/orxcurses
To: [email protected]
Revision: 5521
http://oorexx.svn.sourceforge.net/oorexx/?rev=5521&view=rev
Author: wdashley
Date: 2010-01-31 00:48:46 +0000 (Sun, 31 Jan 2010)
Log Message:
-----------
New tests. The prefresh API seems not to work so I am using a
workaround. Including some code in the header file from Jean-Louis to
support compiling under Windows and PDCurses.
Modified Paths:
--------------
incubator/orxcurses/ncurses.cls
incubator/orxcurses/orxncurses.cpp
incubator/orxcurses/orxncurses.h
Added Paths:
-----------
incubator/orxcurses/test11-1.rex
incubator/orxcurses/test11-2.rex
Modified: incubator/orxcurses/ncurses.cls
===================================================================
--- incubator/orxcurses/ncurses.cls 2010-01-29 16:18:46 UTC (rev 5520)
+++ incubator/orxcurses/ncurses.cls 2010-01-31 00:48:46 UTC (rev 5521)
@@ -48,7 +48,7 @@
::class Window public
-::ATTRIBUTE stdscr class private
+::ATTRIBUTE stdscr class
-- chtype constants
::CONSTANT A_NORMAL 0
@@ -272,7 +272,8 @@
::METHOD init
if arg() = 0 & .window~stdscr() = 'STDSCR'then do
use strict arg
- .window~stdscr = self~first_init()
+ self~first_init()
+ .window~stdscr = self
end
else if arg() = 1 then do
use strict arg ptr
@@ -542,12 +543,26 @@
::METHOD init EXTERNAL "LIBRARY orxncurses OrxCurNewpad"
-::METHOD echochar EXTERNAL "LIBRARY orxncurses OrxCurPechochar"
-::METHOD pechochar EXTERNAL "LIBRARY orxncurses OrxCurPechochar"
+::METHOD echochar
+return self~ERR
::METHOD mvwin
return self~ERR
+::METHOD pechochar EXTERNAL "LIBRARY orxncurses OrxCurPechochar"
+::METHOD pnoutrefresh EXTERNAL "LIBRARY orxncurses OrxCurPnoutrefresh"
+--::METHOD prefresh EXTERNAL "LIBRARY orxncurses OrxCurPrefresh"
+::METHOD prefresh
+use strict arg minrow, mincol, sminrow, smincol, smaxrow, smaxcol
+.window~stdscr()~copywin(self, minrow, mincol, sminrow, smincol,
smaxrow, smaxcol, .false)
+.window~stdscr()~refresh()
+return self~OK
+::METHOD redrawwin
+return self~ERR
+::METHOD refresh
+return self~ERR
::METHOD scroll
return self~ERR
+::METHOD scrollok
+return self~ERR
::METHOD scrl
return self~ERR
::METHOD subpad
@@ -556,12 +571,6 @@
return .window~new(ptr)
::METHOD subwin
return self~ERR
-::METHOD pnoutrefresh EXTERNAL "LIBRARY orxncurses OrxCurPnoutrefresh"
-::METHOD prefresh EXTERNAL "LIBRARY orxncurses OrxCurPrefresh"
-::METHOD redrawwin
-return self~ERR
-::METHOD refresh EXTERNAL "LIBRARY orxncurses OrxCurPrefresh"
--- ::METHOD subpad EXTERNAL "LIBRARY orxncurses OrxCurSubpad"
::METHOD wnoutrefresh
return self~ERR
Modified: incubator/orxcurses/orxncurses.cpp
===================================================================
--- incubator/orxcurses/orxncurses.cpp 2010-01-29 16:18:46 UTC (rev 5520)
+++ incubator/orxcurses/orxncurses.cpp 2010-01-31 00:48:46 UTC (rev 5521)
@@ -1574,7 +1574,8 @@
CSELF, cself, // Self
int, n)
{
- char buf[n + 1];
+ char *buf = (char *)malloc(n + 1);
+ RexxObjectPtr tmp;
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
@@ -1583,7 +1584,9 @@
return 0;
}
wgetnstr((WINDOW *)cself, buf, n);
- return context->NewStringFromAsciiz(buf);
+ tmp = context->NewStringFromAsciiz(buf);
+ free(tmp);
+ return tmp;
}
/**
@@ -1625,7 +1628,8 @@
int, x,
int, n)
{
- char buf[n + 1];
+ char *buf = (char *)malloc(n + 1);
+ RexxObjectPtr tmp;
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
@@ -1634,7 +1638,9 @@
return 0;
}
mvwgetnstr((WINDOW *)cself, SUBTRACTONE(y), SUBTRACTONE(x), buf, n);
- return context->NewStringFromAsciiz(buf);
+ tmp = context->NewStringFromAsciiz(buf);
+ free(tmp);
+ return tmp;
}
/**
@@ -2279,7 +2285,8 @@
CSELF, cself, // Self
int, n)
{
- char buf[n + 1];
+ char *buf = (char *)malloc(n + 1);
+ RexxObjectPtr tmp;
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
@@ -2288,12 +2295,14 @@
return 0;
}
winnstr((WINDOW *)cself, buf, n);
- return context->NewStringFromAsciiz(buf);
+ tmp = context->NewStringFromAsciiz(buf);
+ free(tmp);
+ return tmp;
}
/**
- * Method: OrxCurMvinstr
- *
+ * Method: OrxCurMvinstr
+
* Read a string from the terminal after moving the cursor.
*
* @param y New y position for the cursor.
@@ -2340,7 +2349,8 @@
int, x,
int, n)
{
- char buf[n + 1];
+ char *buf = (char *)malloc(n + 1);
+ RexxObjectPtr tmp;
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
@@ -2349,7 +2359,9 @@
return 0;
}
mvwinnstr((WINDOW *)cself, SUBTRACTONE(y), SUBTRACTONE(x), buf, n);
- return context->NewStringFromAsciiz(buf);
+ tmp = context->NewStringFromAsciiz(buf);
+ free(tmp);
+ return tmp;
}
/**
@@ -2972,7 +2984,7 @@
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(1),
- context->NewStringFromAsciiz("Window"));
+ context->NewStringFromAsciiz("Pad"));
return 0;
}
return pechochar((WINDOW *)cself, (chtype)ch);
@@ -3011,7 +3023,7 @@
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(1),
- context->NewStringFromAsciiz("Window"));
+ context->NewStringFromAsciiz("Pad"));
return 0;
}
return pnoutrefresh((WINDOW *)cself, SUBTRACTONE(minrow),
SUBTRACTONE(mincol),
@@ -3022,7 +3034,7 @@
/**
* Method: OrxCurPrefresh
*
- * Refresh the pad and turn nCurses formatting on.
+ * Refresh the pad to the stdscr.
*
* @param minrow Minimum row number.
*
@@ -3040,7 +3052,7 @@
**/
RexxMethod7(int, // Return type
OrxCurPrefresh, // Object_method name
- CSELF, cself, // Self
+ CSELF, cself, // Pad
int, minrow,
int, mincol,
int, sminrow,
@@ -3052,7 +3064,7 @@
if (cself == NULL) {
context->RaiseException2(Rexx_Error_Incorrect_method_noclass,
context->WholeNumberToObject(1),
- context->NewStringFromAsciiz("Window"));
+ context->NewStringFromAsciiz("Pad"));
return 0;
}
return prefresh((WINDOW *)cself, SUBTRACTONE(minrow), SUBTRACTONE(mincol),
Modified: incubator/orxcurses/orxncurses.h
===================================================================
--- incubator/orxcurses/orxncurses.h 2010-01-29 16:18:46 UTC (rev 5520)
+++ incubator/orxcurses/orxncurses.h 2010-01-31 00:48:46 UTC (rev 5521)
@@ -51,7 +51,17 @@
#include <string.h>
#include <stdio.h>
#include <oorexxapi.h>
+#ifdef WIN32
+#define NCURSES_MOUSE_VERSION 1
+#include <curses.h>
+#define NCURSES_VERSION curses_version()
+#define NCURSES_CAST(type,value) (type)(value)
+#define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,c)])
+// returns the attribute used for the soft keys.
+inline int slk_attr() { return 0; } // To investigate !
+#else
#include <ncurses.h>
+#endif
/*----------------------------------------------------------------------------*/
@@ -59,7 +69,6 @@
/*----------------------------------------------------------------------------*/
-
/*----------------------------------------------------------------------------*/
/* Function Prototypes
*/
/*----------------------------------------------------------------------------*/
Added: incubator/orxcurses/test11-1.rex
===================================================================
--- incubator/orxcurses/test11-1.rex (rev 0)
+++ incubator/orxcurses/test11-1.rex 2010-01-31 00:48:46 UTC (rev 5521)
@@ -0,0 +1,68 @@
+#!/usr/bin/rexx
+/*----------------------------------------------------------------------------*/
+/*
*/
+/* Copyright (c) 2010-2010 Rexx Language Association. All rights
reserved. */
+/*
*/
+/* This program and the accompanying materials are made available
under */
+/* the terms of the Common Public License v1.0 which accompanies this
*/
+/* distribution. A copy is also available at the following address:
*/
+/* http://www.oorexx.org/license.html
*/
+/*
*/
+/* Redistribution and use in source and binary forms, with or
*/
+/* without modification, are permitted provided that the following
*/
+/* conditions are met:
*/
+/*
*/
+/* Redistributions of source code must retain the above copyright
*/
+/* notice, this list of conditions and the following disclaimer.
*/
+/* Redistributions in binary form must reproduce the above copyright
*/
+/* notice, this list of conditions and the following disclaimer in
*/
+/* the documentation and/or other materials provided with the
distribution. */
+/*
*/
+/* Neither the name of Rexx Language Association nor the names
*/
+/* of its contributors may be used to endorse or promote products
*/
+/* derived from this software without specific prior written
permission. */
+/*
*/
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS */
+/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*/
+/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*/
+/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT */
+/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED */
+/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, */
+/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY */
+/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING */
+/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*/
+/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
*/
+/* Authors;
*/
+/* W. David Ashley <[email protected]>
*/
+/*
*/
+/*----------------------------------------------------------------------------*/
+
+
+numeric digits 12
+lf = '0A'x
+
+scr = .window~new()
+
+p = .pad~new(50, 100)
+if p = .nil then do
+ scr~addstr("Unable to create pad")
+ scr~refresh()
+ scr~getch()
+ scr~endwin()
+ return
+ end
+
+--scr~addstr("New pad created")
+--scr~refresh()
+p~addstr("New pad created")
+p~prefresh(1, 1, 1, 1, 2, 16)
+scr~getch()
+
+scr~endwin()
+return
+
+
+::requires 'ncurses.cls'
+
Property changes on: incubator/orxcurses/test11-1.rex
___________________________________________________________________
Added: svn:executable
+ *
Added: incubator/orxcurses/test11-2.rex
===================================================================
--- incubator/orxcurses/test11-2.rex (rev 0)
+++ incubator/orxcurses/test11-2.rex 2010-01-31 00:48:46 UTC (rev 5521)
@@ -0,0 +1,82 @@
+#!/usr/bin/rexx
+/*----------------------------------------------------------------------------*/
+/*
*/
+/* Copyright (c) 2010-2010 Rexx Language Association. All rights
reserved. */
+/*
*/
+/* This program and the accompanying materials are made available
under */
+/* the terms of the Common Public License v1.0 which accompanies this
*/
+/* distribution. A copy is also available at the following address:
*/
+/* http://www.oorexx.org/license.html
*/
+/*
*/
+/* Redistribution and use in source and binary forms, with or
*/
+/* without modification, are permitted provided that the following
*/
+/* conditions are met:
*/
+/*
*/
+/* Redistributions of source code must retain the above copyright
*/
+/* notice, this list of conditions and the following disclaimer.
*/
+/* Redistributions in binary form must reproduce the above copyright
*/
+/* notice, this list of conditions and the following disclaimer in
*/
+/* the documentation and/or other materials provided with the
distribution. */
+/*
*/
+/* Neither the name of Rexx Language Association nor the names
*/
+/* of its contributors may be used to endorse or promote products
*/
+/* derived from this software without specific prior written
permission. */
+/*
*/
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS */
+/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*/
+/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*/
+/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT */
+/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED */
+/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, */
+/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY */
+/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING */
+/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*/
+/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
*/
+/* Authors;
*/
+/* W. David Ashley <[email protected]>
*/
+/*
*/
+/*----------------------------------------------------------------------------*/
+
+
+numeric digits 12
+lf = '0A'x
+filename = 'Readme.txt'
+tall = 24
+wide = 19
+spacer = 5
+
+scr = .window~new()
+
+p = .pad~new(200, wide)
+
+strm = .stream~new(filename)
+strm~open('read')
+eof = .false
+call on notready name eof
+
+ch = strm~charin()
+do while \eof
+ p~addch(ch)
+ ch = strm~charin()
+ end
+strm~close()
+
+p~prefresh(1, 1, 1, 1, tall, wide)
+p~prefresh(tall, 1, 1, wide + spacer, tall, (wide * 2) + spacer - 1)
+p~prefresh(tall * 2, 1, 1, (wide * 2) + (spacer * 2), tall, (wide *3)
+ (spacer * 2) - 1)
+
+scr~getch()
+
+scr~endwin()
+return
+
+
+eof:
+eof = .true
+return
+
+
+::requires 'ncurses.cls'
+
This was sent by the SourceForge.net collaborative development
platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Oorexx-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-svn
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel