2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2012-03-24 14:06:46 -04:00
|
|
|
* Copyright 2006, 2011 Fidelity Information Services, Inc *
|
2012-02-05 11:35:58 -05:00
|
|
|
* *
|
|
|
|
* This source code contains the intellectual property *
|
|
|
|
* of its copyright holder(s), and is made available *
|
|
|
|
* under a license. If you do not know the terms of *
|
|
|
|
* the license, please stop and do not read further. *
|
|
|
|
* *
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "mdef.h"
|
|
|
|
|
|
|
|
#include "compiler.h"
|
|
|
|
|
|
|
|
#ifdef UNICODE_SUPPORTED
|
|
|
|
#include "toktyp.h"
|
|
|
|
#include "opcode.h"
|
|
|
|
#include "advancewindow.h"
|
|
|
|
#include "gtm_conv.h"
|
|
|
|
|
|
|
|
error_def(ERR_BADCASECODE);
|
|
|
|
error_def(ERR_BADCHSET);
|
|
|
|
error_def(ERR_COMMA);
|
|
|
|
|
|
|
|
/* $ZCONVERT(): 3 parameters (3rd optional) - all are string expressions.
|
2012-03-24 14:06:46 -04:00
|
|
|
* For 2 argument $ZCONVERT, if 2nd argument is a literal, must be one of
|
|
|
|
* "U", "L", or "T" (case independent) or else raise BADCASECODE error.
|
|
|
|
* For 3 argument $ZCONVERT, if 2nd or 3rd arguments are literals, they
|
|
|
|
* must be one of "UTF-8", "UTF-16LE", or "UTF-16BE" (case independent)
|
|
|
|
* or else raise BADCHSET error.
|
|
|
|
*/
|
2012-02-05 11:35:58 -05:00
|
|
|
int f_zconvert(oprtype *a, opctype op)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
triple *r, *mode, *mode2;
|
2012-02-05 11:35:58 -05:00
|
|
|
mstr *tmpstr;
|
2012-03-24 14:06:46 -04:00
|
|
|
DCL_THREADGBL_ACCESS;
|
2012-02-05 11:35:58 -05:00
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
SETUP_THREADGBL_ACCESS;
|
|
|
|
r = maketriple(op);
|
|
|
|
if (EXPR_FAIL == expr(&(r->operand[0]), MUMPS_STR))
|
|
|
|
return FALSE;
|
|
|
|
if (TK_COMMA != TREF(window_token))
|
|
|
|
{
|
|
|
|
stx_error(ERR_COMMA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
advancewindow();
|
2012-02-05 11:35:58 -05:00
|
|
|
/* 2nd parameter (required) */
|
|
|
|
mode = newtriple(OC_PARAMETER);
|
|
|
|
r->operand[1] = put_tref(mode);
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(&(mode->operand[0]), MUMPS_STR))
|
|
|
|
return FALSE;
|
2012-02-05 11:35:58 -05:00
|
|
|
/* Check for 3rd parameter */
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{ /* 3rd parameter does not exist. Do checks for 2 arument $zconvert */
|
|
|
|
if (mode->operand[0].oprval.tref->opcode == OC_LIT &&
|
|
|
|
-1 == verify_case((tmpstr = &mode->operand[0].oprval.tref->operand[0].oprval.mlit->v.str)))
|
|
|
|
{
|
|
|
|
stx_error(ERR_BADCASECODE, 2, tmpstr->len, tmpstr->addr);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else
|
2012-03-24 14:06:46 -04:00
|
|
|
{ /* 3rd parameter exists .. reel it in after error checking 2nd parm */
|
2012-02-05 11:35:58 -05:00
|
|
|
r->opcode = OC_FNZCONVERT3;
|
|
|
|
if (mode->operand[0].oprval.tref->opcode == OC_LIT &&
|
|
|
|
0 >= verify_chset((tmpstr = &mode->operand[0].oprval.tref->operand[0].oprval.mlit->v.str)))
|
|
|
|
{
|
|
|
|
stx_error(ERR_BADCHSET, 2, tmpstr->len, tmpstr->addr);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
advancewindow();
|
|
|
|
mode2 = newtriple(OC_PARAMETER);
|
|
|
|
mode->operand[1] = put_tref(mode2);
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(&(mode2->operand[0]), MUMPS_STR))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
if (mode2->operand[0].oprval.tref->opcode == OC_LIT &&
|
|
|
|
0 >= verify_chset((tmpstr = &mode2->operand[0].oprval.tref->operand[0].oprval.mlit->v.str)))
|
|
|
|
{
|
|
|
|
stx_error(ERR_BADCHSET, 2, tmpstr->len, tmpstr->addr);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
ins_triple(r);
|
|
|
|
*a = put_tref(r);
|
|
|
|
return TRUE;
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#else /* Unicode is not supported */
|
|
|
|
int f_zconvert(oprtype *a, opctype op)
|
|
|
|
{
|
|
|
|
GTMASSERT;
|
|
|
|
}
|
|
|
|
#endif
|