Commit 9d187537 authored by Kevin Bracey's avatar Kevin Bracey
Browse files

* Merged in (via sbrodie's branch) public source release of RISC_OSLib.

* Fixed C library tty so it can output '\b' (backspace).
* Made offsetof() and va_arg() macros work with C++.

Version 5.34. Tagged as 'RISC_OSLib-5_34'
parent 8159da18
......@@ -341,6 +341,8 @@ ROM_OBJS =\
rm_o_rl.fileicon \
rm_o_rl.flex \
rm_o_rl.font \
rm_o_rl.fontlist \
rm_o_rl.fontselect \
rm_o_rl.heap \
rm_o_rl.magnify \
rm_o_rl.menu \
......@@ -387,12 +389,12 @@ RLIB_OBJS =\
o_rl.colourtran o_rl.coords o_rl.ctl o_rl.dbox o_rl.dboxfile o_rl.dboxquery \
o_rl.dboxtcol o_rl.dragasprit o_rl.drawcheck o_rl.drawfdiag o_rl.drawfiles \
o_rl.drawfobj o_rl.drawmod o_rl.drawtextc o_rl.event o_rl.fileicon o_rl.flex \
o_rl.font o_rl.heap o_rl.help o_rl.magnify o_rl.menu o_rl.msgs o_rl.os \
o_rl.pointer o_rl.poll o_rl.print o_rl.res o_rl.resspr o_rl.saveas o_rl.sprite \
o_rl.swi o_rl.template o_rl.trace o_rl.txt o_rl.txt1 o_rl.txt3 o_rl.txtar \
o_rl.txtedit o_rl.txtfile o_rl.txtfind o_rl.txtmisc o_rl.txtopt o_rl.txtoptmenu \
o_rl.txtregexp o_rl.txtscrap o_rl.txtundo o_rl.txtwin o_rl.visdelay \
o_rl.werr o_rl.wimp o_rl.wimpt o_rl.win o_rl.xferrecv o_rl.xfersend
o_rl.font o_rl.fontlist o_rl.fontselect o_rl.heap o_rl.help o_rl.magnify o_rl.menu \
o_rl.msgs o_rl.os o_rl.pointer o_rl.poll o_rl.print o_rl.res o_rl.resspr \
o_rl.saveas o_rl.sprite o_rl.swi o_rl.template o_rl.trace o_rl.txt o_rl.txt1 \
o_rl.txt3 o_rl.txtar o_rl.txtedit o_rl.txtfile o_rl.txtfind o_rl.txtmisc \
o_rl.txtopt o_rl.txtoptmenu o_rl.txtregexp o_rl.txtscrap o_rl.txtundo o_rl.txtwin \
o_rl.visdelay o_rl.werr o_rl.wimp o_rl.wimpt o_rl.win o_rl.xferrecv o_rl.xfersend
#
# Objects for RISCOSLIB:o.riscoslibm
......@@ -403,13 +405,13 @@ RLIB_MOD_OBJS =\
m_o_rl.dboxfile m_o_rl.dboxquery m_o_rl.dboxtcol m_o_rl.dragasprit \
m_o_rl.drawcheck m_o_rl.drawfdiag m_o_rl.drawfiles m_o_rl.drawfobj m_o_rl.drawmod \
m_o_rl.drawtextc m_o_rl.event m_o_rl.fileicon m_o_rl.flex m_o_rl.font \
m_o_rl.heap m_o_rl.help m_o_rl.magnify m_o_rl.menu m_o_rl.msgs m_o_rl.os \
m_o_rl.pointer m_o_rl.poll m_o_rl.print m_o_rl.res m_o_rl.resspr m_o_rl.saveas \
m_o_rl.sprite m_o_rl.swi m_o_rl.template m_o_rl.trace m_o_rl.txt m_o_rl.txt1 \
m_o_rl.txt3 m_o_rl.txtar m_o_rl.txtedit m_o_rl.txtfile m_o_rl.txtfind \
m_o_rl.txtmisc m_o_rl.txtopt m_o_rl.txtoptmenu m_o_rl.txtregexp \
m_o_rl.txtscrap m_o_rl.txtundo m_o_rl.txtwin m_o_rl.visdelay m_o_rl.werr \
m_o_rl.wimp m_o_rl.wimpt m_o_rl.win m_o_rl.xferrecv m_o_rl.xfersend
m_o_rl.fontlist m_o_rl.fontselect m_o_rl.heap m_o_rl.help m_o_rl.magnify \
m_o_rl.menu m_o_rl.msgs m_o_rl.os m_o_rl.pointer m_o_rl.poll m_o_rl.print \
m_o_rl.res m_o_rl.resspr m_o_rl.saveas m_o_rl.sprite m_o_rl.swi m_o_rl.template \
m_o_rl.trace m_o_rl.txt m_o_rl.txt1 m_o_rl.txt3 m_o_rl.txtar m_o_rl.txtedit \
m_o_rl.txtfile m_o_rl.txtfind m_o_rl.txtmisc m_o_rl.txtopt m_o_rl.txtoptmenu \
m_o_rl.txtregexp m_o_rl.txtscrap m_o_rl.txtundo m_o_rl.txtwin m_o_rl.visdelay \
m_o_rl.werr m_o_rl.wimp m_o_rl.wimpt m_o_rl.win m_o_rl.xferrecv m_o_rl.xfersend
#
# Build rules:
......
......@@ -11,14 +11,14 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.33"
Module_Version SETA 533
Module_MajorVersion SETS "5.34"
Module_Version SETA 534
Module_MinorVersion SETS ""
Module_Date SETS "10 May 2001"
Module_ApplicationDate2 SETS "10-May-01"
Module_ApplicationDate4 SETS "10-May-2001"
Module_Date SETS "23 Aug 2001"
Module_ApplicationDate2 SETS "23-Aug-01"
Module_ApplicationDate4 SETS "23-Aug-2001"
Module_ComponentName SETS "RISC_OSLib"
Module_ComponentPath SETS "RiscOS/Sources/Lib/RISC_OSLib"
Module_FullVersion SETS "5.33"
Module_HelpVersion SETS "5.33 (10 May 2001)"
Module_FullVersion SETS "5.34"
Module_HelpVersion SETS "5.34 (23 Aug 2001)"
END
/* (5.33)
/* (5.34)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 5.33
#define Module_MajorVersion_CMHG 5.34
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 10 May 2001
#define Module_Date_CMHG 23 Aug 2001
#define Module_MajorVersion "5.33"
#define Module_Version 533
#define Module_MajorVersion "5.34"
#define Module_Version 534
#define Module_MinorVersion ""
#define Module_Date "10 May 2001"
#define Module_Date "23 Aug 2001"
#define Module_ApplicationDate2 "10-May-01"
#define Module_ApplicationDate4 "10-May-2001"
#define Module_ApplicationDate2 "23-Aug-01"
#define Module_ApplicationDate4 "23-Aug-2001"
#define Module_ComponentName "RISC_OSLib"
#define Module_ComponentPath "RiscOS/Sources/Lib/RISC_OSLib"
#define Module_FullVersion "5.33"
#define Module_HelpVersion "5.33 (10 May 2001)"
#define Module_FullVersion "5.34"
#define Module_HelpVersion "5.34 (23 Aug 2001)"
......@@ -312,7 +312,7 @@ int _ttywrite(const unsigned char *buf, unsigned int len, int flag)
if (ch == '\n') {
if (_kernel_oswrch(LF) < 0) return -1;
ch = CR;
} else if (ch < 32 && ch != 0x07 && !isspace(ch)) {
} else if (ch < 32 && ch != 0x07 && ch != 0x08 && !isspace(ch)) {
if (_kernel_oswrch('|') < 0) return -1;
ch = (ch & 31) | 64;
}
......
......@@ -18,7 +18,7 @@
/* stdarg.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.8 */
/* Copyright (C) Codemist Ltd. */
/* Copyright (C) Acorn Computers Ltd. 1991, 1992 */
/* version 3.00 */
/* version 3.01 */
#ifndef __stdarg_h
#define __stdarg_h
......@@ -44,6 +44,22 @@ typedef char *va_list[1]; /* see <stdio.h> */
* is passed as an argument it gets passed by reference.
*/
#ifdef __cplusplus
template <class T> struct __alignoftest
{ char __member1; T __member2;
};
#define __alignof(type) \
((char *)&(((__alignoftest<type>*) 0)->__member2) - (char *)0)
#define __alignuptotype(ptr,type) \
((char *)((int)(ptr) + (__alignof(type)-1) & ~(__alignof(type)-1)))
#define va_start(ap,parmN) \
((void)(*(ap) = (char *)&(parmN) + sizeof(parmN)))
#define va_arg(ap,type) \
(*(type *)((*(ap)=__alignuptotype(*(ap),type)+sizeof(type))-\
sizeof(type)))
#else
/* Note that ___type is a syntactic item a bit like the type qualifiers */
/* 'static', 'register', 'const' etc except that it has no effect! Its */
/* purpose is to indicate when a type is being introduced and thus */
......@@ -56,13 +72,6 @@ typedef char *va_list[1]; /* see <stdio.h> */
((char *)((int)(ptr) + (__alignof(type)-1) & ~(__alignof(type)-1)))
#ifdef __cplusplus
#define va_start(ap,parmN) \
((void)(*(ap) = (char *)&(parmN) + sizeof(parmN)))
#define va_arg(ap,type) \
(*(___type type *)((*(ap)=__alignuptotype(*(ap),type)+sizeof(___type type))-\
sizeof(___type type)))
#else
#define va_start(ap,parmN) \
(___assert((___typeof(parmN) & 0x481) == 0, \
"Illegal type of 2nd argument to va_start"), \
......
......@@ -18,7 +18,7 @@
/* stddef.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.1.4 */
/* Copyright (C) Codemist Ltd. */
/* Copyright (C) Acorn Computers Ltd. 1991, 1992 */
/* version 2.00 */
/* version 2.01 */
/*
* The following types and macros are defined in several headers referred to in
......@@ -58,8 +58,13 @@ typedef int wchar_t; /* also in <stdlib.h> */
/* null pointer constant. */
#endif
#ifdef __cplusplus
#define offsetof(type, member) \
((size_t)((char *)&(((type *)0)->member) - (char *)0))
#else
#define offsetof(type, member) \
((size_t)((char *)&(((___type type *)0)->member) - (char *)0))
#endif
/*
* expands to an integral constant expression that has type size_t, the
* value of which is the offset in bytes, from the beginning of a structure
......
......@@ -63,7 +63,7 @@ int akbd_pollkey(int *keycode /*out*/)
/* bona fide function key */
*keycode = 256 + x;
} else {
/* he's typing ahead with a control-@: sorry boy, you loose
/* he's typing ahead with a control-@: sorry boy, you lose
the next key. */
*keycode = 0;
};
......
/* Copyright 2001 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/************************************************************************/
/* © Acorn Computers Ltd, 1992. */
/* */
/* This file forms part of an unsupported source release of RISC_OSLib. */
/* */
/* It may be freely used to create executable images for saleable */
/* products but cannot be sold in source form or as an object library */
/* without the prior written consent of Acorn Computers Ltd. */
/* */
/* If this file is re-distributed (even if modified) it should retain */
/* this copyright notice. */
/* */
/************************************************************************/
/*
* Title: fontlist.c
* Purpose: Code to enumerate the fonts available into a tree structure
* History: IDJ: 06-Feb-92: prepared for source release
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "werr.h"
#include "wimp.h"
#include "wimpt.h"
#include "win.h"
#include "event.h"
#include "baricon.h"
#include "res.h"
#include "resspr.h"
#include "menu.h"
#include "template.h"
#include "dbox.h"
#include "fontlist.h"
#include "fontselect.h"
#include "msgs.h"
#include "akbd.h"
#include "font.h"
#ifndef UROM
/* -------------------------------------------------- */
/* Globals defined */
/* -------------------------------------------------- */
fontlist_node *font__tree = NULL;
/* -------------------------------------------------- */
/* Functions defined */
/* -------------------------------------------------- */
/* Create a tree of all the available fonts in font__tree, returning NULL if an error occurred.
system is TRUE if the system font is to appear in the tree */
extern fontlist_node *font__list_all_fonts( BOOL system );
/* Free the font tree structure */
extern void font__free_font_tree( fontlist_node *font_tree );
/* Add a new font to the font tree strucutre */
static fontlist_node *font__add_new_font( fontlist_node **font_list_ptr, char *font_name );
/* Find the position of a font entry in the tree (creating it if necessary first) */
static fontlist_node *font__seek_font( fontlist_node **font_list_ptr, char **font_name_ptr, BOOL rest_of_name );
/* Allocate memory for a font entry for the tree */
static fontlist_node *font__allocate_new_font( void );
/* Deallocate memory for a font entry for the tree */
static void font__deallocate_font( fontlist_node *font_tree );
/* -------------------------------------------------- */
/* Function to create a list of the available fonts */
/* -------------------------------------------------- */
/*
Create a tree of all the available fonts in font__tree,
returning NULL if an error occurred.
system is TRUE if the system font is to appear in the tree
*/
/* -------------------------------------------------- */
extern fontlist_node *fontlist_list_all_fonts( BOOL system )
{
int font_count = 0;
char font[40];
if (system)
font__add_new_font( &font__tree, "System" );
while (font_count != -1)
{
if ( wimpt_complain(font_list( font, &font_count ) ) != NULL)
return NULL;
if (font_count != -1)
if ( font__add_new_font( &font__tree, font ) == NULL )
{
werr(0, "No room for font list.\n");
return NULL;
}
}
return font__tree;
}
/* -------------------------------------------------- */
/* Free the font tree structure */
/* -------------------------------------------------- */
extern void fontlist_free_font_tree( fontlist_node *font_tree )
{
font__deallocate_font( font_tree );
}
/* -------------------------------------------------- */
/* Add a new font to the font tree strucutre */
/* -------------------------------------------------- */
static fontlist_node *font__add_new_font( fontlist_node **font_list_ptr, char *font_name )
{
fontlist_node *font_ptr;
/* Find/create font with the first portion of the font name */
font_ptr = font__seek_font( font_list_ptr, &font_name, FALSE );
/* NULL => no room to create the font entry */
if (font_ptr==NULL)
return NULL;
/* Find/create weight of font */
if (*font_name != '\0')
{
font_ptr = font__seek_font( &font_ptr->son, &font_name, FALSE );
if (font_ptr==NULL)
return NULL;
/* Find/create style of font */
if (*font_name != '\0')
{
font_ptr = font__seek_font( &font_ptr->son, &font_name, TRUE );
if (font_ptr==NULL)
return NULL;
}
}
/* Now we have found/created the complete font */
font_ptr -> flag = TRUE;
return font_ptr;
}
static fontlist_node *font__seek_font( fontlist_node **font_list_ptr, char **font_name_ptr, BOOL rest_of_name )
{
int i;
if (*font_list_ptr == NULL)
{
if ((*font_list_ptr = font__allocate_new_font()) == NULL)
return NULL;
(*font_list_ptr) -> flag = FALSE;
(*font_list_ptr) -> son = NULL;
(*font_list_ptr) -> brother = NULL;
strcpy((*font_list_ptr)->name, *font_name_ptr);
if (rest_of_name)
{
*font_name_ptr += strlen( *font_name_ptr );
}
else
{
for ( i=0; (**font_name_ptr != '\0') && (**font_name_ptr != '.'); i++ )
(*font_name_ptr)++;
if (**font_name_ptr != '\0')
{
(*font_list_ptr)->name[i] = '\0';
(*font_name_ptr)++;
}
}
return *font_list_ptr;
}
for (i=0; ((*font_name_ptr)[i] != '\0' && (rest_of_name || (*font_name_ptr)[i] != '.')) ;i++);
if ( ( strncmp( *font_name_ptr, (*font_list_ptr)->name, i) != 0 ) ||
( (*font_list_ptr)->name[i]!='\0' ) )
return font__seek_font( &((*font_list_ptr)->brother), font_name_ptr, rest_of_name );
(*font_name_ptr) += i;
if ( **font_name_ptr == '.' )
(*font_name_ptr)++;
return *font_list_ptr;
}
/* -------------------------------------------------- */
/* Allocate memory for a font entry for the tree */
/* -------------------------------------------------- */
static fontlist_node *font__allocate_new_font( void )
{
return (fontlist_node *) (malloc(sizeof(fontlist_node)));
}
/* -------------------------------------------------- */
/* Deallocate memory for a font entry from the tree */
/* -------------------------------------------------- */
static void font__deallocate_font( fontlist_node *font )
{
if (font!=NULL)
{
font__deallocate_font( font->brother );
font__deallocate_font( font->son );
free( (void *) font);
}
}
#endif /* UROM */
This diff is collapsed.
......@@ -12,4 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define VERSION "4.17 (06 Nov 1990)"
#define VERSION "5.34 (18 Aug 2001)"
/* Copyright 2001 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****************************************************************************
* This source file was written by Acorn Computers Limited. It is part of *
* the RISCOS library for writing applications in C for RISC OS. It may be *
* used freely in the creation of programs for Archimedes. It should be *
* used with Acorn's C Compiler Release 3 or later. *
* *
***************************************************************************/
/*
* Title: fontlist.h
* Purpose: Routines to enumerate the fonts on the system into a tree structure
*
*/
#ifndef __fontlist_h
#define __fontlist_h
/* -------------------------------------------------- */
/* Structures required */
/* -------------------------------------------------- */
typedef struct fontlist_node
{
char name[40];
struct fontlist_node *son;
struct fontlist_node *brother;
int flag;
} fontlist_node;
/* As an example of a font tree structure, consider
Corpus.Medium, Corpus.Bold, Selwyn,
Trinity.Medium, Trinity.Bold, Trinity.Medium.Italic,
Widget.Medium.Italic.Outline
This will be stored in the following way: (#'s denote flag's which are TRUE)
--+--> Corpus --+--> # Medium
| |
| +--> # Bold
|
+--> # Selwyn
|
+--> Trinity --+--> # Medium -----> # Italic
| |
| +--> # Bold
|
+--> Widget --+--> Medium -----> # Italic.Outline
[ Brothers are connected vertically downwars, sons to their parents
right-to-left ]
*/
/* -------------------------------------------------- */
/* Globals defined */
/* -------------------------------------------------- */
extern fontlist_node *font__tree;
/* --------------------------- fontlist_list_all_fonts -----------------------------
* Description: Read in the font list into a font tree
*
* Parameters: BOOL system -- TRUE if System font should be included in the list
* Returns: a pointer to the start of the font tree
* Other Info:
*/
fontlist_node *fontlist_list_all_fonts( BOOL system );
/* --------------------------- fontlist_free_font_tree -----------------------------
* Description: Free a font tree
*
* Parameters: fontlist_node *font_tree -- the font tree to free
* Returns:
* Other Info:
*/
void fontlist_free_font_tree( fontlist_node *font_tree );
#endif
/* end fontlist.h */
/* Copyright 2001 Pace Micro Technology plc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/****************************************************************************
* This source file was written by Acorn Computers Limited. It is part of *
* the RISCOS library for writing applications in C for RISC OS. It may be *
* used freely in the creation of programs for Archimedes. It should be *
* used with Acorn's C Compiler Release 3 or later. *
* *
***************************************************************************/
/*
* Title: fontselect.h
* Purpose: Consistent interface to font choosing
*
*/
#ifndef __fontselect_h
#define __fontselect_h
typedef BOOL (*fontselect_fn)(char *font_name, double width, double height, wimp_eventstr *event );
/* --------------------------- fontselect_init -----------------------------
* Description: Read in the font list and prepare data for the font selector window
*
* Parameters:
* Returns: TRUE if initialisation succeeded.
* Other Info:
*/
int fontselect_init( void );
/* --------------------------- fontselect_closedown -----------------------------
* Description: Close the font selector windows if they are open, and free the font selector data structures
*
* Parameters:
* Returns:
* Other Info: This call is provided to return the machine to the state it was in before a call of fontselect_init()
*/
void fontselect_closedown( void );
/* --------------------------- fontselect_closewindows -----------------------------
* Description: Close the font selector windows if they are open
*
* Parameters:
* Returns:
* Other Info: This call will close the font selector windows and unattach the handlers, if they are open.
*/
void fontselect_closewindows( void );
/* --------------------------- fontselect_selector -----------------------------
* Description: Opens up or reopens the font chooser window.
*
* Parameters: char *title -- The title for the window (can be NULL if flags SETTITLE is clear)
* int flags -- The flags for the call (see below)
* char *font_name -- The font name to set the window contents to (only if SETFONT is set)
* double width -- The width in point size of the font
* double height --
* fontselect_fn unknown_icon --
* Returns: The window handle of the font selector main window, if the function
* call was successful. Otherwise it returns 0.
* Other Info: The flags word allows the call to have different effects.
* If fontselect_SETFONT is set then the window contents wil be updated to reflect the font choice passed in
* If fontselect_SETTITLE is set then the title of the window will be set, otherwise title is ignored.
* If fontselect_REOPEN is set then the font selector will only open the window if it is already open. This
* lets the application update the contents of the window only if it is currently open.
* Note that the fontselect_init() must be called before this routine.
*/
int fontselect_selector( char *title, int flags, char *font_name, double width, double height, fontselect_fn unknown_icon_routine );
#define fontselect_REOPEN 0x001
#define fontselect_SETTITLE 0x002
#define fontselect_SETFONT 0x004
/* ---------------------------- fontselect_attach_menu ----------------------------
* Description: Attaches a menu to all four font selector windows
*
* Parameters: menu mn -- menu to attach
* event_menu_proc menu_processor -- menu processor for the menu events
* void *handle -- handle to pass to the menu processor
* Returns: TRUE if the menus were attached, FALSE otherwise
* Other Info: none.
*/
BOOL fontselect_attach_menu(